This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] new setting to not-print frame arguments values


Hello,

Context:
--------

As a user, I had often wished that there would be a way to print
backtraces without printing any argument, almost like the way we
print a frame for a function that does not have any debug info.
This is because the argument values tend to clutter the part of
the backtrace that I am really interested in.

But recently, a bug that we fixed causing arguments to be printed
correctly instead of not printed at all, had the unexpected side-effect
of dramatically slowing down the printing of each frame in a backtrace.

The slow-down is due to the encoding used for Ada, which requires
what we call "parallel lookups", which are lookups that scan through
the entire application. This is because we are forced by non-dwarf
debugging info (stabs) to use parallel types to help us determine
certain characteristics that can not be encoded otherwise. This is
hardly noticeable on small projects, but quite annoying on large
scale projects.

These lookups are only used for non-scalar types, such as records
and arrays. So, since we cannot do without the parallel lookups
for now, the following idea emerged.

Proposal:
---------

We would like to propose the inclusion of a new setting:

    (gdb) set print frame-arguments (all|scalars|none)

The effect would be:

  (a) set print frame-arguments all
      print all argument values. Same behavior as before.


  (b) set print frame-arguments scalars
      print the argument value only if the argument is a scalar.

  (c) set print frame-arguments none
      Print no argument value at all.

When the argument value is not printed, its value is substituted
with "..." to give the user a clue that the value has intentionally
not been printed.

For our needs, AdaCore will set the default "print frame-arguments"
to "scalars", but we may here want to preserve the default behavior,
and thus use "all" by default.

This is what this patch implements. Testcase and documentation
are still missing, but will be provided later if the idea is accepted.

The testcase will be in C, but for now, with Ada, here is the output
we get for each value of this new switch:

    (gdb) set print frame-arguments all 
    (gdb) frame
    #1  0x0804954f in pck.call_me (int=1, flt=2.0, bln=true, chr=106 'j', 
        sad=(system.address) 0xbfac2ae4, rec=(a => 3, b => 7)) at pck.adb:17
    17            Break_Me;

    (gdb) set print frame-arguments scalars 
    (gdb) frame
    #1  0x0804954f in pck.call_me (int=1, flt=2.0, bln=true, chr=106 'j', 
        sad=(system.address) 0xbfac2ae4, rec=...) at pck.adb:17
    17            Break_Me;

    (gdb) set print frame-arguments none    
    (gdb) frame
    #1  0x0804954f in pck.call_me (int=..., flt=..., bln=..., chr=..., 
        sad=..., rec=...) at pck.adb:17
    17            Break_Me;


2007-11-06  Joel Brobecker  <brobecker@adacore.com>

        * stack.c (print_frame_arguments_choices): New static global.
        (print_frame_arguments): Likewise.
        (print_this_frame_argument_p): New function.
        (print_frame_args): Print the argument value only when appropriate.
        (_initialize_task): Add new "set/show print frame-arguments" command.

Tested on x86-linux. No regression.

Any comments? Let's be bold: Ok to checkin? ;-)

Thanks,
-- 
Joel

Attachment: stack.c.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]