Dave
Dave

Reputation: 1641

Debugging in VS Code with lldb, how do I set a breakpoint on a symbol I don't have source for?

I have some kind of memory management bug that, of course, happens randomly every 3 days or so under 100% load. This is on OSX, but it's all plain, portable C++11:

code(12404,0x70000aace000) malloc: *** error for object 0x105088e00: pointer being freed was not allocated
                         *** set a breakpoint in malloc_error_break to debug
  Abort trap: 6

I'm using Visual Studio Code and the debugger is lldb; what I do not know is -how- to set a breakpoint on malloc_error_break so I can look at the call stack when it happens.

VS Code lets you set breakpoints at source code lines, but I do not have source code for that system library code, just the symbol. But if I could break there, regardless of not having source for that function, I could inspect the call stack.

So, how to set a breakpoint in lldb under Visual Studio Code on OSX High Sierra at an arbitrary symbol without source code?

Thanks!

Upvotes: 2

Views: 4681

Answers (3)

mrclng
mrclng

Reputation: 543

Eventhough the question is quite old I think it might still be interesting for others. Also, I'm assuming you actually want to do what your code is telling you to do (set a breakpoint in malloc_error_break) as opposed to the more general task of 'setting a breakpoint on a symbol you don't have source for'. If that's the case, consider updating your question title ac

@buszkiraly's answer is close, but actually related to Visual Studio. In Visual Studio Code you find the setting in the menu under Run > New Breakpoint > Function Breakpoint. However, this only seems to do anything if you already have an active debugging session!

If you do have one open, you can also just click on the + icon in the lower left corner.

In both cases you should see something like the image below

Then just type malloc_error_break and hit enter to get...

Now running your code with a debugger attached should break when reaching the

Upvotes: 0

buszkiraly
buszkiraly

Reputation: 193

If you go to Debug->New Breakpoint->Function Breakpoint, you can add this breakpoint by entering the function name (malloc_error_break).

Upvotes: 2

Kamil.S
Kamil.S

Reputation: 5543

Not sure about the Visual Studio Code part, but in lldb you can do it with:

br s -F malloc_error_break

or simply

b malloc_error_break

Upvotes: 0

Related Questions