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]

[RFA] no frame needed when computing address of subprogram


Trying to compute the address of a procedure fails when the inferior
is not running:

        (gdb) p foo'address
        No registers.

To reproduce, use the trivial Ada program pasted at the end of
this email, and compile it with:

        % gnatmake -g foo

Then try the command above.

The problem is inside eval.c:evaluate_subexp_for_address, in the case
handling the OP_VAR_VALUE case. Unless we are in EVAL_AVOID_SIDE_EFFECT
mode, we end up doing:

      if (noside == EVAL_AVOID_SIDE_EFFECTS)
      [...]
      else
        return
          locate_var_value
          (var,
           block_innermost_frame (exp->elts[pc + 1].block));

In particular, we are trying to get the block_innermost_frame,
which doesn't exist in our case. The attached patch changes
that to first check that we need a frame to get the object
address, otherwise, we locate the value without a frame.

2008-01-01  Paul N. Hilfinger  <hilfinger@adacore.com>

        * eval.c (evaluate_subexp_for_address): Provide frame address to
        locate_var_value only if it will be needed.

I also wrote a tiny testcase that verifies the fix.

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

        * gdb.ada/fun_addr/foo.adb: New file.
        * gdb.ada/fun_addr.exp: New testcase.

All tested on x86-linux, no regression.  The patch has also been in
AdaCore's tree since Aug 2003 (shame on us!).

OK to commit?

Thanks,
-- 
Joel

procedure Foo is
begin
   null;
end Foo;

Attachment: fun_addr.diff
Description: Text document

Attachment: fun_addr-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]