diff options
author | Andrew Burgess <aburgess@redhat.com> | 2024-11-06 22:18:55 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2024-11-08 10:44:43 +0000 |
commit | 31ada87f91b4c5306d81c8a896df9764c32941f3 (patch) | |
tree | b385cdad80903f8f9f82d9016cf50560ccacf670 /gdb/testsuite/gdb.python/py-missing-debug.c | |
parent | 328f42d85b8eb1f3f97e5a1ec97e444a6dd72e33 (diff) | |
download | binutils-31ada87f91b4c5306d81c8a896df9764c32941f3.zip binutils-31ada87f91b4c5306d81c8a896df9764c32941f3.tar.gz binutils-31ada87f91b4c5306d81c8a896df9764c32941f3.tar.bz2 |
gdb: fixes and tests for the 'edit' command
This commit was inspired by this mailing list post:
https://inbox.sourceware.org/gdb-patches/osmtfvf5xe3yx4n7oirukidym4cik7lehhy4re5mxpset2qgwt@6qlboxhqiwgm
When reviewing that patch, the first thing I wanted to do was add some
tests for the 'edit' command because, as far as I can tell, there are
no real tests right now.
The approach I've taken for testing is to override the EDITOR
environment variable, setting this to just 'echo'. Now when the
'edit' command is run, instead of entering an interactive editor, the
shell instead echos back the arguments that GDB is trying to pass to
the editor. The output might look like this:
(gdb) edit
+22 /tmp/gdb/testsuite/gdb.base/edit-cmd.c
(gdb)
We can then test this like any other normal command. I then wrote
some basic tests covering a few situations like, using 'edit' before
the inferior is started. Using 'edit' without any arguments, and
using 'edit' with a line number argument.
There are plenty of cases that are still not tested, for example, the
test program only has a single source file for example. But we can
always add more tests later.
I then used these tests to validate the fix proposed in the above
patch.
The patch above does indeed fix some cases, specifically, when GDB
stops at a location (e.g. a breakpoint location) and then the 'edit'
command without any arguments is fixed. But using the 'list' command
to show some other location, and then 'edit' to edit the just listed
location broken before and after the above patch.
I am instead proposing this alternative patch which I think fixes more
cases. When GDB stops at a location then 'edit' with no arguments
should correctly edit the current line. And using 'list XX' to list a
specific location, followed by 'edit' should also now edit the just
listed location.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17669
Co-Authored-By: LluĂs Batlle i Rossell <viric@viric.name>
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/testsuite/gdb.python/py-missing-debug.c')
0 files changed, 0 insertions, 0 deletions