Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLDB: Setting a breakpoint for malloc_error_break through the console

Tags:

c++

lldb

I'm running into some malloc-related issues in my code:

malloc: *** error for object 0x103401e28: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

I've tried things like:

(lldb) breakpoint set malloc_error_break
error: invalid combination of options for the given command

How do I set this breakpoint using the terminal? I've searched online and only found results involving Xcode.

like image 936
Jerry Feng Avatar asked Mar 04 '15 08:03

Jerry Feng


People also ask

How to set 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.


1 Answers

If you are familiar with gdb, then this little cheat-sheet might help:

http://lldb.llvm.org/lldb-gdb.html

Also:

(lldb) help break set

will give you lots of information about setting breakpoints in lldb.

In this case:

(lldb) br set --name malloc_error_break
(lldb) br set -n malloc_error_break

or:

(lldb) b malloc_error_break

The first examples use breakpoint set which is a "true" lldb command - it uses flag options & values to distinguish the kinds of things you are trying to do. bis a synthetic command that attempts to roughly recreate the gdb breakpoint syntax.

like image 196
Jim Ingham Avatar answered Sep 19 '22 12:09

Jim Ingham