Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB/LLDB break at all functions of specified module/shared library

In lldb, I got help breakpoint set:

       -a <address-expression> ( --address <address-expression> )
        Set the breakpoint at the specified address.  If the address maps uniquely to a particular binary, then the address will be converted to a "file" address, so that the
        breakpoint will track that binary+offset no matter where the binary eventually loads.  Alternately, if you also specify the module - with the -s option - then the
        address will be treated as a file address in that module, and resolved accordingly.  Again, this will allow lldb to track that offset on subsequent reloads.  The
        module need not have been loaded at the time you specify this breakpoint, and will get resolved when the module is loaded.

and

       -r <regular-expression> ( --func-regex <regular-expression> )
        Set the breakpoint by function name, evaluating a regular-expression to find the function name(s).

and

   -s <shlib-name> ( --shlib <shlib-name> )
        Set the breakpoint only in this shared library.  Can repeat this option multiple times to specify multiple shared libraries.

Now I want to set breakpoints at every function of specified module/dylib that you can find in the results of command image list -f.

Take libobjc.A.dylib and MyOwn.dylib as examples. I tried following commands but failed:

(lldb) breakpoint set -r libobjc.A.dylib
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.

(lldb) b +[ThunderManager load]
Breakpoint 2: where = MyOwn.dylib`+[ThunderManager load] +16 at ThunderManager.m:20, address = 0x000000010489f274

(lldb) breakpoint set -r MyOwn.dylib`*
Breakpoint 3: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.

I want lldb get break at all functions of module libobjc.A.dylib or MyOwn.dylib, or any other specified loaded module/shared library. How to set the breakpoints in lldb?

like image 871
isaacselement Avatar asked Jul 05 '17 14:07

isaacselement


People also ask

How do you set a breakpoint in LLDB?

In lldb you can set breakpoints by typing either break or b followed by information on where you want the program to pause. After the b command, you can put either: a function name (e.g., b my_subroutine ) a line number (e.g., b 12 )

How do I stop LLDB?

Type quit to exit the lldb session.

Is LLDB better than GDB?

Both GDB and LLDB are of course excellent debuggers without doubt. GDB is debugger part of the GNU project created to work along the GNU compiler. LLDB is debugger part of the LLVM project created to work along LLVM compiler. The majority of the commands are the same.


1 Answers

(lldb) break set -r . -s libobjc.A.dylib

The -s option takes a shared library as its value, and that limits the breakpoint to the specified shared library. You can specify the -s option more than once to specify more than one shared library for inclusion in the breakpoint search.

The -r option's value is a regular expression; if the symbol name matches that expression, it will be included in the breakpoint. . matches everything.

The lldb tutorial:

http://lldb.llvm.org/tutorial.html

starts with a description of the structure of lldb commands that you might find helpful.

like image 76
Jim Ingham Avatar answered Sep 28 '22 03:09

Jim Ingham