poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alien tokens and GDB integration, and docs


From: Jose E. Marchesi
Subject: Re: Alien tokens and GDB integration, and docs
Date: Sun, 29 Sep 2024 22:10:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

> Hi Jose.
>
> On Wed, Sep 25, 2024 at 12:18:58PM GMT, Jose E. Marchesi wrote:
>> 
>> In poke_alien_token_handler I see:
>> 
>>   /* In GDB delimited alien poke tokens with the form $<&FOO> or $addr::FOO
>>      provide the address of the symbol `FOO' as an offset in bytes, i.e. it
>>      resolves to the GDB value &FOO as a Poke offset with unit bytes
>>      and a magnitude whose width is the number of bits conforming an
>>      address in the target architecture.
>> 
>>      $<FOO> or $FOO, on the other hand, provides the value of the symbol FOO
>>      incarnated in a proper Poke value, provided that FOO is of a type
>>      that this handler knows how to handle.  Otherwise the string is
>>      not recognized as a token.  */
>> 
>> I have a couple of questions:
>> 
>> - FOO in $FOO shall be an identifier referring to some GDB symbol, but
>>   FOO in $<FOO> can be any GDB expression, like in $<2 + 3>, correct?
>>   It would be good for the comment to reflect this, and the
>>   documentation as well.
>
>
> Right.  OK.
>
>> 
>> - Is it really necessary to handle $<&EXPR> as a special case in
>>   poke_alien_token_handler?  If `foo' is a GDB symbol, then `&foo' is a
>>   valid expression.  Instead of checking for startswith (expr, "&"), the
>>   code could ask GDB for the type of `value'.  If it is a pointer type,
>>   then create an offset alien token.
>
>
> Correct. Works for most of the cases, but not all!
>
> `&foo' is valid syntax in C, C++, Go and Rust. So works out of the box.
>
> It's not valid syntax in Ada and (I think) Fortran, but gdb accepts `&foo' 
> and does the
> right thing.
>
> This is how they've extended Ada grammar to accept this 
> (binutils-gdb/gdb/ada-exp.y):
>
> ```
> /* Some extensions borrowed from C, for the benefit of those who find they
>    can't get used to Ada notation in GDB.  */
>
> primary :       '*' primary             %prec '.'
>                         { ada_wrap<ada_unop_ind_operation> (); }
>         |       '&' primary             %prec '.'
>                         { ada_addrof (); }
>         |       primary '[' exp ']'
>                         {
>                           ada_wrap2<subscript_operation> (BINOP_SUBSCRIPT);
>                           ada_wrap<ada_wrapped_operation> ();
>                         }
>         ;
>
> ```
>
> But! This is not implemented for Modula-2, so `&foo' is not recongnized!
>
> So I think handling $<&EXPR> as a special case is better.  WDYT?

I don't like the idea of supporting that as a special case.

$<GDB_EXPRESSION> is simple and general.  If the modula2 GDB parser
doesn't provide a way to get an address then that is something to fix at
the GDB side, if it makes sense to fix it at all.

There is also $addr::SYMBOL.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]