diff options
author | Tom Tromey <tom@tromey.com> | 2016-06-20 10:36:29 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-02-26 09:37:03 -0700 |
commit | 6893c19a8b81a399953edbf26aaef6e714a7ab0e (patch) | |
tree | 915d985e090672f9312f7ec8b988c7210c2f6011 /gdb/python | |
parent | 2ddeaf8a7d64094f4caf6cdc412d8162f49f73a1 (diff) | |
download | gdb-6893c19a8b81a399953edbf26aaef6e714a7ab0e.zip gdb-6893c19a8b81a399953edbf26aaef6e714a7ab0e.tar.gz gdb-6893c19a8b81a399953edbf26aaef6e714a7ab0e.tar.bz2 |
Make "bt N" print correct number of frames when using a frame filter
PR python/16497 notes that using "bt" with a positive argument prints
the wrong number of frames when a frame filter is in use. Also, in this
case, the non-frame-filter path will print a message about "More stack
frames" when there are more; but this is not done in the frame-filter
case.
The first problem is that backtrace_command_1 passes the wrong value
to apply_ext_lang_frame_filter -- that function takes the final
frame's number as an argument, but backtrace_command_1 passes the
count, which is off by one.
The solution to the second problem is to have the C stack-printing
code stop at the correct number of frames and then print the message.
Tested using the buildbot.
ChangeLog
2018-02-26 Tom Tromey <tom@tromey.com>
PR python/16497:
* stack.c (backtrace_command_1): Set PRINT_MORE_FRAMES flag. Fix
off-by-one in py_end computation.
* python/py-framefilter.c (gdbpy_apply_frame_filter): Handle
PRINT_MORE_FRAMES.
* extension.h (enum frame_filter_flags) <PRINT_MORE_FRAMES>: New
constant.
2018-02-26 Tom Tromey <tom@tromey.com>
PR python/16497:
* gdb.python/py-framefilter.exp: Update test.
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/py-framefilter.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index e887849c..3a3fb97 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -1355,6 +1355,18 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, gdbpy_enter enter_py (gdbarch, current_language); + /* When we're limiting the number of frames, be careful to request + one extra frame, so that we can print a message if there are more + frames. */ + int frame_countdown = -1; + if ((flags & PRINT_MORE_FRAMES) != 0 && frame_low >= 0 && frame_high >= 0) + { + ++frame_high; + /* This has an extra +1 because it is checked before a frame is + printed. */ + frame_countdown = frame_high - frame_low + 1; + } + gdbpy_ref<> iterable (bootstrap_python_frame_filters (frame, frame_low, frame_high)); @@ -1402,6 +1414,19 @@ gdbpy_apply_frame_filter (const struct extension_language_defn *extlang, break; } + if (frame_countdown != -1) + { + gdb_assert ((flags & PRINT_MORE_FRAMES) != 0); + --frame_countdown; + if (frame_countdown == 0) + { + /* We've printed all the frames we were asked to + print, but more frames existed. */ + printf_filtered (_("(More stack frames follow...)\n")); + break; + } + } + success = py_print_frame (item.get (), flags, args_type, out, 0, levels_printed.get ()); |