IOS Debugging Tips

Source: Internet
Author: User
<span id="Label3"></p><span style="font-size: 18px;"><span style="font-size: 18px;">1. What is lldb? </span></span><p><p><span style="font-size: 18px;">lldb, bottom debugger, in the debug area of xcode, you can see the small blue print (lldb)</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">2. What dSYM file? </span></span><p><p><span style="font-size: 18px;">DsYM is a debug information file because the suffix name. dsYM, so called Sdym file, when creating a new project, the default is to create a DsYM file, build setting has the corresponding settings</span></p></p><p><p><span style="font-size: 18px;"></span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">3. What is symbolic? </span></span><p><p><span style="font-size: 18px;">When the program is running, the source code is turned into the machine code to run, the program once crashed, can collect the crash information, is nothing more than some memory address, hexadecimal code, must be converted to the method name or variable name, to understand the crash information, the process of this conversion is called symbolized, symbolized according to the dSYM file, because the dSYM file, Stores the mappings between the memory address and the method Name.</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">4. Symbolic Method</span></span><p><p><span style="font-size: 18px;">Http://www.cocoachina.com/industry/20140514/8418.html</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">5. Breakpoints</span></span><span style="font-size: 18px;"><span style="font-size: 18px;">5.1 Adding an exception breakpoint</span></span><span style="font-size: 18px;"><span style="font-size: 18px;">5.2 Adding a symbol breakpoint</span></span><p><p><span style="font-size: 18px;">and add the exception breakpoint the same button, choose symbolic breakpoint, symbol breakpoint, usually used to focus on the method you want to focus on (feel more Chicken)</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">5.3 Editing Breakpoints</span></span><p><p><span style="font-size: 18px;">Any breakpoints created by the development can be edited and entered into the editing interface, and the conditions can be edited in Condition. For example, a 100-time cycle, you need to hit a breakpoint on the 50th time, you can write index>50 in condition (not necessarily index, determined by the condition variable in the for loop), this is more useful</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">5.4 Shared Breakpoints</span></span><p><p><span style="font-size: 18px;">In the left navigation bar of xcode, switch to the breakpoint navigation bar interface, Press and hold CRTL click a breakpoint, you can choose share, you can upload the breakpoint to the version control system, this is very chicken</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">6. Observation Points</span></span><p><p><span style="font-size: 18px;">When the program runs, you can select a variable in the left part of the debug area, hold down ctrl, click a variable, and then click watch, and once the value of the variable is sent, the old and new values are automatically printed in the console, and the observer is automatically added to the breakpoint navigation, which is more useful, Used to monitor global variables or singleton property values</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">7. Debug the artifact in Lldb</span></span><span style="font-size: 18px;"><span style="font-size: 18px;">7.1 Print Variables</span></span><p><p><span style="font-size: 18px;">When using breakpoints to track problems, if you forget to nslog, you can print with P or po, p prints non-container variables, PO print container variables, such as dictionaries, arrays, and Collections.</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">7.2 Print View hierarchies</span></span><p><p><span style="font-size: 18px;">  </span><span style="font-size: 18px;">Recursivedescription is not auto-complete, hit Enter to see the printing effect,</span> <span style="font-size: 18px;">For example [self.tableview recursivedescription]</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">7.3 Print Registers</span></span><p><p><span style="font-size: 18px;">Register read, Once the program crashes, you can look at the print registers, listed methods, to narrow down the scope of the Investigation.</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">7.4 Lldb supports Python scripting language</span></span><span style="font-size: 18px;"><span style="font-size: 18px;">8. Enable Zombie Object Check</span></span><p><p><span style="font-size: 18px;">Under arc, It doesn't seem to be much use. But under mrc, this is a big use.</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">9. Crash Type</span></span><span style="font-size: 18px;"><span style="font-size: 18px;">9.1 exc_bad_access</span></span><p><p><span style="font-size: 18px;">When you access an object that has been disposed of or sends a message to it, it appears</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">9.2 SIGSEGV</span></span><p><p><span style="font-size: 18px;">Segment Error signal, is a more serious error generated by the operating System. There may be hardware errors, access to unreadable memory addresses, or writing data to protected memory Addresses.</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">9.3 Sigbus</span></span><p><p><span style="font-size: 18px;">The memory accessed is an invalid memory address</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">9.4 SIGTRAP</span></span><p><p><span style="font-size: 18px;">When this error is encountered, LLDB is usually automatically paused on the corresponding line code</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">9.5 exc_arithmetic</span></span><p><p><span style="font-size: 18px;">Except 0 o'clock, there will be</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">9.6 Sigill</span></span><p><p><span style="font-size: 18px;">Illegal command signal</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">9.7 SIGABRT</span></span><p><p><span style="font-size: 18px;">Stop signal</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">9.8 watchdog timeout</span></span><p><p><span style="font-size: 18px;">Error code 0x8badf00d, often read as ate bad food (very much like), common in the synchronization queue to send requests, blocking the main thread</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">10. Custom C function to handle SIGABRT signal</span></span><p><p><span style="font-size: 18px;">Can see Uncaughtexceptionhandler open source Class</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">11. Assertions</span></span><p><p><span style="font-size: 18px;">It is recommended that you remove assertions in the release version and otherwise record assertions in the log System.</span></p></p><p><p><span style="font-size: 18px;">Assertions are best always matched with the IF condition</span></p></p><p><p><span style="font-size: 18px;">int i = 4;</span></p></p><p><p><span style="font-size: 18px;">if (i = = 4) {</span></p></p><p><p><span style="font-size: 18px;"><span style="color: #008000;">//do something</span></span></p></p><p><p><span style="font-size: 18px;">} else {</span></p></p><p><p><span style="font-size: 18px;">Nsassert (no,@ "i Not equal to 4");</span></p></p><p><p><span style="font-size: 18px;">}</span></p></p><span style="font-size: 18px;"><span style="font-size: 18px;">in The. OC program, It is not recommended to use @throw and @catch to catch exceptions, or to use assertions (if it is a release version, it is logged in the log System)</span></span><span style="font-size: 18px;"><span style="font-size: 18px;">13. Collect crash reports, third-party crash reporting services, Quincykit (charge), TestFlight (free)</span></span><p><p></p></p><p><p>IOS Debugging Tips</p></p></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.