I have several breakpoints set up. They are numbered from 6 to 6.38.
I want to delete a range. Based on this I can do it. However when I
(gdb) delete breakpoints 6-6.2
I get a following response
inverted range
When I
(gdb) delete breakpoints 6.1-6.2
I get
warning: bad breakpoint number at or near '6.1-6.2'
I googled in many places but I wasn't able to find a proper way to specify ranges. Does anybody know what is the right way to specify ranges?
I would really appreciate any help on this.
In gdb, when a breakpoint has multiple locations, you can't delete just an individual location. This is a bit of an oddity in the gdb CLI.
This is why delete 6.1-6.3 doesn't work. The error message could certainly be better here.
One thing you can do instead is disable just the locations you don't want. Offhand I am not sure if disable 6.1-6.3 will work -- you might have to type out disable 6.1, disable 6.2, etc.
Related
When running GDB, the debugger would print the current line it's at to give you an indication of where it's currently at.
Seeing as I'm on Mavericks, GDB doesn't seem to be an option, and as such I'm forced to use LLDB. My question is: How do I get similar behaviour from LLDB?
Currently all it does is print 7 or-so lines of code with an arrow pointing at the current line, rather than just printing the line it's on, which is rather cluttered to look at. LLDB also seems to ignore all output produced by printf
Is there a way to achieve the same, or similar results using LLDB?
I don't think the question you asked is exactly what you intended. I assume you mean "How to get LLDB to print ONLY the current line" since, as you noted, it always prints the current line along with some lines of context.
Anyway, how many lines of source get printed when you stop is controlled by the two settings:
stop-line-count-after -- The number of sources lines to display that come after the current source line when displaying a stopped context.
stop-line-count-before -- The number of sources lines to display that come before the current source line when displaying a stopped context.
Actually these aren't quite right, since setting both to 0 shows no source lines, but setting "after" to 1 shows TWO stop lines. Somebody apparently wanted to make it possible to show NO source lines, but didn't want to add an extra setting.
Anyway, you can't get just one line, but you can get it down to two.
Is it possible to change the location of an existing GDB breakpoint?
I've set one on a particular line, and then added a condition to it. I would like to move it to a different line number, but retain the condition without having to destroy it and retype the condition.
I'm using GDB 7.5 on RedHat Enterprise Linux 5 64bit.
Any help much appreciated.
It is not possible to do this.
It would be a nice addition, but nobody has implemented it yet.
You can use "save breakpoints" and then edit the result and source it. This may be handy if the condition is very complicated.
How about the following?
break +offset
break -offset
Set a breakpoint some number of lines forward or back from the position at which execution stopped in the currently selected frame.
(see http://www.ofb.net/gnu/gdb/gdb_29.html#SEC29)
I am trying to grab the addresses that associated with the start of the source code and the one at the end. I tried to do it using LLVM, Clang but I could not.
Is there a way to get the memory addresses that associated of each line in the source code?
Thanks
There are several possibilities:
You can use debug information for this. Note, however, that this
information might not be precise for optimized code
Alternatively,
you can use special linker script which will insert two symbols
before and after all the code in the code section.
Is there a way to store the output of the last command in gdb to a string? What I would like to do is store the address information of selected machine level instructions. Redirecting the output is not a solution as it would generate too much output. A simulator would also be a solution, but I'd like to see if it would be possible with gdb as I only want the analysis on a small chunk of code.
So I would need something like this:
(gdb) display/i $pc
(gdb) 1: x/i $pc 0x100000d2e <main+61>: jle 0x100000d02 <main+17
(gdb) set $foo = ??? somehow set this to display line 1
(gdb) call myFunc($foo)
(I excluded the looping controls to keep the example simple)
Or would there be another way of doing this?
Not possible as far as I know, which is kind of surprising considering all the Lisp background of the author :) You'd need either redirection (grep, sed, and awk make wonders on large files, and there's always perl), or your own instruction decoding based on $pc, which I assume is not an option.
Then I don't really understand what you are trying to do. Figure out jump targets? Relocation correctness? What is that you don't know about the code until the runtime? More details can probably point into better direction.
Edit:
Just some links - haven't tried it yet - you might want to play with script-extension setting and see if you can make Python command files work for you:
see Extending GDB and Python in GDB.
GDB, at least as it's configured by default on my Ubuntu 9.04 box, doesn't handle multi-line statements well. When I'm stepping through code, GDB only displays the last line of the current statement, even if that statement spans multiple lines.
I'm aware that I could use DDD or emacs as a frontend for GDB, but I'd prefer to solve this problem within GDB, if that's possible.
Does anyone know if there's a way to get GDB to do the right thing here?
How about running GDB with the text user interface?
gdb -tui
It makes a world of difference to the ease of use of GDB.
I'm afraid the answer is "no, there is no way to get gdb to do what you want".
The line info in the symbol tables associates each code instruction with a single
source line (not a source statement). gdb has no way of knowing that several
source lines are associated with the same source statement.