Hot answers tagged

8

LLDB >= 3.4 has the -o / --one-line command line option that can be used to launch your program automatically: lldb -o run /bin/true For reference here are two relevant snippets from lldb-3.6 --help: ... -o --one-line Tells the debugger to execute this one-line lldb command after any file provided on the command line has been ...


8

Binaries are usually stripped. For ELF binaries, you can check it with file command $ file /bin/true /bin/true: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x73796652ea437df8ac7b3ba1864a7ac177e27600, stripped Notice the stripped at the end of file's result. It means, among ...


6

You can make use of the command (lldb) process launch --stop-at-entry to start the program. This stops you right at the entry point. From there lldb will tell you the address as well, in case this is what you are interested in. If instead you were interested in the actual main function, and not the entry point, you should have a look at the related ...


6

From http://lldb.llvm.org/tutorial.html: (lldb) process launch --stop-at-entry -- -program_arg value Note your break main is a gdb command; lldbs error message isnt "no such symbol", it's "invalid command". To do the same in lldb, use (lldb) breakpoint set --name main


5

I'm surprised nobody posted an answer, but here's what I eventually came to realize: A lot of times disassembling is used for taking apart potential malicious apps like viruses, worms, or malware to understand how they affect a system. There is both static and dynamic disassembly. Static disassembly poses (little) threat to your system as it is only looking ...


4

The Calculator app is stripped as can be seen by running nm. You will need to find the address of the method using class-dump: $ class-dump -A /Applications/Calculator.app | grep showAbout - (void)showAbout:(id)arg1; // IMP=0x0000000100009939 However as the Calculator application is already running, the address has been slided because of ASLR. To find the ...


3

I solved this problem for gdb a few years ago, see Import class-dump info into GDB on Stack Overflow. I’m not sure if lldb has an add-symbol-file equivalent command. Loading symbols from location in memory from the lldb-dev mailing list suggests that you may have to create your own .dSYM file instead of a .stabs file.


3

The reason is due to address space layout randomization (ASLR). The dynamic loader will employ some randomization in the starting address (the slide) which you must account for. When you start the application in lldb, no slide is applied so the addresses are the same. Here is an example of it in action from two different Calculator apps running 0x00000200 ...


2

As for workaround (per this post), on Linux the non-executable binary can be invoked by dynamic linker/loader as below: lldb -- /lib64/ld-linux-x86-64.so.2 foo_binary and for 32-bit version use ld-linux.so found in /lib instead.


2

No. lldb wants to run the program using a combination of fork and exec, then control the progam with ptrace. But the kernel will refuse to exec the program unless it has the correct x bit (your user/group ids define which one is the correct one) set. You can set the x bit for yourself, the owner, only (if you want to prevent others from executing the binary);...


2

Try this: (lldb) break set -n main (lldb) r (lldb) thread backtrace frame #0: 0x0000000000405696 app`main(argc=1, argv=...) + 22 at app.cpp:11 frame #1: 0x00007ffff7216ec5 libc.so.6`__libc_start_main + 245 frame #2: 0x0000000000401f79 app The frame below (before) main is the one you want, and it's showing the library and function name. You can set a ...


2

I was able to achieve this by installing gdbserver on my ipad. Then i ssh into the ipad and attach a remote lldb debugger (xcode tools) to attack breakpoints. A long method but works. There are now tools to debug in same way on android and ios.


2

So there is an answer in the original post, but what i was missing is the interface where i'll be attaching the debugger at in the boot-args so I have to add kdp_match_name=en24, where en24 is the physical interface the machines are communicating at Just adding here the answer as well, as it might help someone in the future


2

For the overflow from name to command to work, the difference between the addresses of both should be 0x10 bytes. I verified what I mentioned in the case earlier - Adding printf("%p:%p\n", name, command); Under a debugger stepping through main gives the addresses as 0x100404080:0x1002059f0 Here delta > 0x10 bytes and hence the name strcpy ...


2

You can probably find the details in GDB’s source code but I think it just single-steps the program until the condition matches. IIRC this is done for any condition that can’t be handled by a hardware breakpoint.


1

It seems it should be the one with mach_msg_trap but looks like you'll need to do some hex dump hunting to recover the real call stack...


1

Because the functions were never called. The app indeed tricked me. It's not because a function is named user_click_on_blue_button that it will be called when the user click on the blue button. Another function, with a less obvious name, was used instead. Can't find my previous account, so using a new one.


1

Referencing variables with $ only works in the shell or if the program specifically supports it. You simply have to paste or type the old value manually. Possibly you can use Python scripting to read and write the environment variables.


1

You can use strace: strace --instruction-pointer --stack-traces -e write ./your-app This will show the place in the binary, for instance: [00007fe942df6537] write(1, "c", 1c) = 1 > /usr/lib64/libc-2.31.so(write+0x17) [0xf2537] > /usr/lib64/libc-2.31.so(_IO_file_write@@GLIBC_2.2.5+0x2c) [0x8285c] > /usr/lib64/libc-2.31.so(...


1

Although lldb help doesn't explicitly state gdb's info functions equivalent, it shows the command mapped from info function <FUNC_REGEX>. Nonetheless, you may realise that info functions in gdb gives you the same output as info function .*, where .* is the regular expression that matches every function name. That being said, from GDB to LDB command ...


1

Since the Objc data (selectors) has to be available to the Objc code in order for it to run. LLDB can set breakpoints according to selectors using the breakpoint set -n "[SomeClass someFunction:]" command. You can also check the LLDB tutorial.


1

This might be stupid, but you say you are debugging the ARM64 binary, and yet in IDA Pro it says you are disassembling the ARMv7 binary. So you are disassembling the incorrect binary in IDA Pro. To fix this, open the binary in 64 bit version of IDA Pro. It will automatically disassemble the 64 bit binary.


1

Try adding a breakpoint on a bad address. In GDB, the way I do this is: b *0xf00, or something similar. Here's what it looks like for me in GDB, and maybe you'll find a way to duplicate the same behavior: $ gdb ./a.out (gdb) b *0xf00 (gdb) r Starting program: ./a.out Warning: Cannot insert breakpoint 1. Cannot access memory at address 0xf00 (gdb) x/2i $...


Only top voted, non community-wiki answers of a minimum length are eligible