I’m trying to use -break-insert and the -f flag for it.
I noticed in MICmdCmdBreak.cpp , in CmICmdCmdBreakInsert::ParseArgs() that the -f has a required parameter.
m_setCmdArgs.Add(new CMICmdArgValOptionShort(m_constStrArgNamedPendinfBrkPt, false, true,
Based on the GDB MI documentation (at GDB/MI Breakpoint Commands (Debugging with GDB)) for -break-insert shows:
If location cannot be parsed (for example if it refers to unknown files or functions), create a pending breakpoint. Without this flag, gdb will report an error, and won’t create a breakpoint, if location cannot be parsed.
Is there a reason why it requires a parameter and what should this parameter be ?
gdb used to try to find a symbol matching the breakpoint specification and if it didn't find one immediately, it would raise an error. If you didn't want this behavior (in a world with many shared libraries you seldom did) then you could set a "future-break" which is what the -f flag turns on. This was better though a bit bogus, because it would set the breakpoint the FIRST time it took, then never look again.
But this was quite a while ago, and I think gdb's gotten better about organizing breakpoints. But I haven't used a modern gdb for a while, so I'm not sure how it works now-a-days.
Anyway, lldb's breakpoints don't work that way. They stay active till you delete them, and keep searching for new matches every time a shared library is loaded. You could make them emulate the gdb behavior by judiciously deleting & duplicating breakpoints from the original specification, but there's no way to get the native lldb breakpoints to do so (nor should there be IMHO...)
So if you are using the lldb-mi, there's no reason to bother with the -f flag. But also lldb-mi should probably just ignore this flag.
If I don't specify the -f flag (with some random parameter), then a pending breakpoint is not created and the initial binding fails. But if I specify the -f with the random parameter, then it will bind when the library is loaded. This is the behavior I see on gdb also, but sans the random parameter. I looked at the source code and can't figure out what it expects the parameter to be and what it does with the value.
This is what Eclipse does when setting a breakpoint at main on a Hexagon target, before -exec-run:
TX:21-break-insert -t -f main
So the instance I run into the error is setting a conditional breakpoint:
-break-insert -f -c "x==0" main.cpp:13
And I get:
MI: Error: Command Args. Validation failed. Args missing additional information: f
^error,msg="Command 'break-insert'. Command Args. Validation failed. Args missing additional information: f"
It seems in the tests/examples, -f is the last parameter and the function/code location happens after the -f.
Does this seem like a bug or am I misunderstanding what the -f flag does on -break-insert ?
That is my understanding of what the -f flag is supposed to do. It doesn't take an argument, it just directs gdb to do "future-break" rather than "break". The lldb MI should probably just parse & discard it.
It looks like the current implementation expects the -f to be right before the break location. So "-break-insert main" or "-break-insert -t -f main -d" would work, but "-break-insert -t main -f -d" would not.
It also looks as if restricting the breakpoint to the thread id (incorrectly) only works if a condition is set.
Cool. I'll put together a bug report and a possible fix.
Thanks for looking at it!