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]

[commit/Ada] Always print parameters passed by reference


Consider the following code:

   type Data is record
      One      : Integer;
      Two      : Integer;
      Three    : Integer;
      Four     : Integer;
      Five     : Integer;
      Six      : Integer;
   end record;

   procedure Call_Me (D : in out Data);

In procedure Call_Me, parameter D ends up being passed by reference.
As a result, when stopping inside this procedure, the debugger will
print:

    (gdb) run
    Starting program: /[...]/foo 
    
    Breakpoint 1, pck.call_me (d=) at pck.adb:5
    5             if D.One > D.Two then

As you can see, the parameter value is entirely missing. Normally,
when a parameter is passed by reference, the debugger is expected
to print the parameter address. But in the case of Ada, it would
be confusing to an Ada user, as references is not something that
they would be familiar with except if they were writing the compiler.
So it is usually more useful to print the entire parameter value
rather than the address.  This is what this patch does, it changes
the above into the below:

    Breakpoint 1, pck.call_me (d=
            (one => 1, two => 2, three => 3, four => 4, five => 5, six => 6))
        at pck.adb:5
    5             if D.One > D.Two then

2008-01-01  Joel Brobecker  <brobecker@adacore.com>

        * ada-valprint.c (ada_val_print_1) [TYPE_CODE_REF]: Ignore deref_ref
        and always print the dereferenced value.

I also wrote a new testcase for this change:

2008-01-01  Joel Brobecker  <brobecker@adacore.com>

        * gdb.ada/ref_param/foo.adb, gdb.ada/ref_param/pck.adb,
        gdb.ada/ref_param/pck.ads: New files.
        * gdb.ada/ref_param.exp: New testcase.

Tested on x86-linux. No regression.
Checked in.

-- 
Joel

Attachment: ref_param.diff
Description: Text document

Attachment: ref_param-testcase.diff
Description: Text document


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