summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
Commit message (Collapse)AuthorAgeFilesLines
* gdb/testsuite: remove use of then keyword from gdb.python/*.expAndrew Burgess2022-11-281-2/+2
| | | | | | | | | | | | The canonical form of 'if' in modern TCL is 'if {} {}'. But there's still a bunch of places in the testsuite where we make use of the 'then' keyword, and sometimes these get copies into new tests, which just spreads poor practice. This commit removes all use of the 'then' keyword from the gdb.python/ test script directory. There should be no changes in what is tested after this commit.
* gdb: add prepare_reinflate/reinflate around print_frame_args in ↵Simon Marchi2022-11-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | info_frame_command_core I noticed this crash: $ ./gdb --data-directory=data-directory -nx -q \ testsuite/outputs/gdb.python/pretty-print-call-by-hand/pretty-print-call-by-hand \ -x testsuite/outputs/gdb.python/pretty-print-call-by-hand/pretty-print-call-by-hand.py \ -ex "b g" -ex r (gdb) info frame Stack level 0, frame at 0x7fffffffdd80: rip = 0x555555555160 in g (/home/simark/src/binutils-gdb/gdb/testsuite/gdb.python/pretty-print-call-by-hand.c:41); saved rip = 0x5555555551a3 called by frame at 0x7fffffffdda0 source language c. Arglist at 0x7fffffffdd70, args: mt=mytype is 0x555555556004 "hello world", depth=10 Fatal signal: Segmentation fault This is another case of frame_info being invalidated under a function's feet. The stack trace when the frame_info get invalidated looks like: ... many frames to pretty print the arg, that eventually invalidate the frame_infos ... #35 0x00005568d0a8ab24 in print_frame_arg (fp_opts=..., arg=0x7ffc3216bcb0) at /home/simark/src/binutils-gdb/gdb/stack.c:489 #36 0x00005568d0a8cc75 in print_frame_args (fp_opts=..., func=0x621000233210, frame=..., num=-1, stream=0x60b000000300) at /home/simark/src/binutils-gdb/gdb/stack.c:898 #37 0x00005568d0a9536d in info_frame_command_core (fi=..., selected_frame_p=true) at /home/simark/src/binutils-gdb/gdb/stack.c:1682 print_frame_args knows that print_frame_arg can invalidate frame_info objects, and therefore calls prepare_reinflate/reinflate. However, info_frame_command_core has a separate frame_info_ptr instance (it is passed by value / copy). So info_frame_command_core needs to know that print_frame_args can invalidate frame_info objects, and therefore needs to prepare_reinflate/reinflate as well. Add those calls, and enhance the gdb.python/pretty-print-call-by-hand.exp test to test that command. Reviewed-By: Bruno Larsen <blarsen@redhat.com> Change-Id: I9edaae06d62e97ffdb30938d364437737238a960
* gdb/frame: Add reinflation method for frame_info_ptrBruno Larsen2022-10-101-0/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, despite having a smart pointer for frame_infos, GDB may attempt to use an invalidated frame_info_ptr, which would cause internal errors to happen. One such example has been documented as PR python/28856, that happened when printing frame arguments calls an inferior function. To avoid failures, the smart wrapper was changed to also cache the frame id, so the pointer can be reinflated later. For this to work, the frame-id stuff had to be moved to their own .h file, which is included by frame-info.h. Frame_id caching is done explicitly using the prepare_reinflate method. Caching is done manually so that only the pointers that need to be saved will be, and reinflating has to be done manually using the reinflate method because the get method and the -> operator must not change the internals of the class. Finally, attempting to reinflate when the pointer is being invalidated causes the following assertion errors: check_ptrace_stopped_lwp_gone: assertion `lp->stopped` failed. get_frame_pc: Assertion `frame->next != NULL` failed. As for performance concerns, my personal testing with `time make chec-perf GDB_PERFTEST_MODE=run` showed an actual reduction of around 10% of time running. This commit also adds a testcase that exercises the python/28856 bug with 7 different triggers, run, continue, step, backtrace, finish, up and down. Some of them can seem to be testing the same thing twice, but since this test relies on stale pointers, there is always a chance that GDB got lucky when testing, so better to test extra. Regression tested on x86_64, using both gcc and clang. Approved-by: Tom Tomey <tom@tromey.com>
* gdb/testsuite: remove gdb.python/pretty-print-call-by-hand.expSimon Marchi2022-03-241-127/+0
| | | | | | | | | | | | | | | | This test was added without a corresponding fix, with some setup_kfails. However, it results in UNRESOLVED results when GDB is built with ASan. ERROR: GDB process no longer exists GDB process exited with wait status 1946871 exp7 0 1 UNRESOLVED: gdb.python/pretty-print-call-by-hand.exp: frame print: backtrace test (PRMS gdb/28856) Remove the test from the tree, I'll attach it to the Bugzilla bug instead [1]. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=28856 Change-Id: Id95d8949fb8742874bd12aeac758aa4d7564d678
* [gdb/testsuite] test a function call by hand from pretty printerBruno Larsen2022-03-211-0/+127
The test case added here is testing the bug gdb/28856, where calling a function by hand from a pretty printer makes GDB crash. There are 6 mechanisms to trigger this crash in the current test, using the commands backtrace, up, down, finish, step and continue. Since the failure happens because of use-after-free (more details below) the tests will always have a chance of passing through sheer luck, but anecdotally they seem to fail all of the time. The reason GDB is crashing is a use-after-free problem. The above mentioned functions save a pointer to the current frame's information, then calls the pretty printer, and uses the saved pointer for different reasons, depending on the function. The issue happens because call_function_by_hand needs to reset the obstack to get the current frame, invalidating the saved pointer.