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] Fix 'address of array subscript


The attached patch fixes a problem when trying to take the address
of an element inside an array, like so:

    (gdb) p a(2)'Address
    Attempt to take address of non-lval

The expected behavior is to return address of that array element:

    (gdb) print a(2)'Address
    $1 = (system.address) 0xbf8e00ec

The problem was happing during the EVAL_AVOID_SIDE_EFFECTS pass,
because were were creating non-lval value thinking that it would
be enough for the EVAL_AVOID_SIDE_EFFECTS pass. However, this turned
out to be too limited, as subsequent operations on the result might
fail because they require a lval value.

Fixed with the attached patch.

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

        * ada-lang.c (ada_evaluate_subexp): Modify the value returned
        when noside is EVAL_AVOID_SIDE_EFFECTS to be an lval_memory.
        This is needed to make sure that any other treatment applied
        to the resulting value does not fail for spurious reason,
        such as trying to take the address of this value.

I also wrote a new testcase:

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

        * array_subscript_addr/p.adb: New file.
        * array_subscript_addr.exp: New testcase. 

All tested on x86-linux. No regression. Checked in.

-- 
Joel

Attachment: subscript_addr.diff
Description: Text document

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