aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-cmd.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-11-06 22:18:55 +0000
committerAndrew Burgess <aburgess@redhat.com>2024-11-08 10:44:43 +0000
commit31ada87f91b4c5306d81c8a896df9764c32941f3 (patch)
treeb385cdad80903f8f9f82d9016cf50560ccacf670 /gdb/python/py-cmd.c
parent328f42d85b8eb1f3f97e5a1ec97e444a6dd72e33 (diff)
downloadbinutils-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/python/py-cmd.c')
0 files changed, 0 insertions, 0 deletions