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] print $pc when language is Ada


Another long explaination for a small patch :-).

Trying to print the $pc register when the language is Ada trips
an assertion:

    (gdb) start
    Breakpoint 1 at 0x804950f: file foo.adb, line 4.
    Starting program: /[...]/foo 
    foo () at foo.adb:4
    4       end Foo;
    (gdb) p /x $pc
    ../../src-public/gdb/regcache.c:164: internal-error: register_type: Assertion `regnum >= 0 && regnum < descr->nr_cooked_registers' failed.
    [...]

This reproduces with any program, as long as the language is Ada.

The assertion occurs while doing the language->la_post_parser phase. 
During that phase, we do some Ada-specific resolving of the expression,
during which we end up defering the resolution of our OP_REGISTER
node to evaluate_subexp_standard. The evaluation triggers the assertion
because the register number is beyond descr->nr_cooked_registers
when we try to find the register type.

We shouldn't even have tried to evaluate the OP_REGISTER expression
node. There is no reason that I can think of where an OP_REGISTER
node should be rewritten, so we can simply return immediately.
The attached patch fixes this.

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

        * ada-lang.c (resolve_subexp): Add handling of OP_REGISTER
        expressions.  These expressions do not need to be rewriten.

I also wrote a little testcase.

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

        * gdb.ada/print_pc.exp: New testcase.

All tested on x86-linux, no regression. Checked in.

PS: Now down to 29 failures!!! :-)

-- 
Joel

Attachment: pc.diff
Description: Text document

Attachment: pc-tc.diff
Description: Text document


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