Debug Tools for Mac development

Source: Internet
Author: User

Chisel is a small plug-in that strengthens the ability to debug lldb. The main feature is that the interface is developed and debugged in the console to see the elements and conditions of the interfaces as intuitively as possible. To comb the view for us, The controller and the class relationship level. And some temporary interface debugging changes for quick response. Its authors come from the Facebook team. Thanks to open source, let's watch and see what this stuff is all about. It's an open source Lldb plug-in collection, which makes debugging even more interesting.

Lldb

Lldb is an open source debugger with REPL features and C + +, Python plugins.

Have you ever bothered to understand your code and try to print the value of a variable?

NSLog (@ "%@", whatisinsidethisthing);  

or skip a function to simplify the behavior of the program?

This function should actually be called:Foo ();

Or short circuit a logic check?

if (1 | | | thebooleanatstake) {...}

or forge a function implementation?

int Calculatethetrickyvalue {  9;  / *   First of all ...   } 

and must recompile every time, start from the beginning?

Building software is complex, and bugs always occur. A common repair cycle is to modify the code, compile, rerun, and pray for the best results.

But not necessarily. You can use the debugger. And even if you already know how to use the debugger to check variables, it can do a lot more.

This article will try to challenge your understanding of debugging and explain in detail some basic principles that you may not yet understand, and then show a series of interesting examples. Now let's start dancing a waltz with the debugger to see how high the end can be.

Lldb and Python

LLDB has built-in, complete Python support. Entering script in Lldb will open a Python REPL. You can also enter a line of Python statements as arguments to the script command, which can run a Python statement without entering REPL:

Import OS (lldb) script Os.system ("Open http://www.objc.io/")

This allows you to create a variety of cool commands. Put the following statement in the file ~/mycommands.py:

Caflushcommand(debugger, command, result, internal_dict):  debugger. Handlecommand ("E (void) [catransaction flush]") 

Then run in Lldb:

Command Script Import ~/mycommands.py

Or put this line of command in the/.lldbinit, so that every time you enter the LLDB will automatically run. Chisel is actually a collection of Python scripts that stitch (command) strings and then let Lldb execute them. It's simple, isn't it?

Grip the Debugger this weapon

Lldb can do a lot of things. Most people are accustomed to using p,po,n,s and C, but in fact there are many more lldb can do. Mastering all the commands (in fact not many) will allow you to gain greater power when revealing the running state of your code, looking for bugs, and enforcing specific run paths. You can even build simple interactive prototypes-like what if you now pop up a View Controller in modal mode? Use the debugger and try to know.

This article is intended to show you the power of LLDB and encourages you to explore the console input commands.

Open Lldb, enter help, and take a look at the list of commands. How much have you tried? How much did it take?

Hopefully NSLog doesn't look so appealing to you anymore, and it's not fun and time-consuming to run edits every time.

Debug Tools for Mac development

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.