[PATCH 1/2] gdb: Allow address space qualifier parsing in C++.

Simon Marchi simon.marchi@polymtl.ca
Fri Apr 2 16:51:24 GMT 2021


On 2021-04-02 12:48 p.m., Simon Marchi via Gdb-patches wrote:>> This '@address_space_qualifier' is a bit of an undocumented and untested feature AFAIK. Even the avr tests for __flash don't test it.
>> I did search the git history a bit, but couldn't really determine why it was added. Only that it was added years before the __flash patch was.
>> But since it is there and since I need a language agnostic way to specify this, I plan to use it for a future target.
>>
>> The only test I could currently write for this patch is something like:
>> gdb_test "*(@somerandomqualifiername int *) 0x12345678" "Unknown address space specifier: \"somerandomqualifiername\""> 
>> for a C++ program on any target. If you think that is valuable, I can easily add that.
>> The target I want to use this for in the end won't be ready for upstream for a while unfortunately.
> 
> Hi Felix,
> 
> I think it would be valuable to have a test like this.  It's better
> than nothing, and it's always good to check error cases to make sure GDB
> doesn't crash on them.  I can imagine that this test could test with
> both a C and C++ program to cover everything correctly (and maybe other
> languages, but I don't know much about them, if that even applies to
> them).
> 
> A while ago I added a simavr board file, to be able to run tests against
> an AVR target.  simavr is easy to build and use (it may even be packaged
> in distros, but I'd be tempted to use the latest available version).
> All of this to say you could try to run and improve the flash qualifier
> test for AVR (or write a new test).
> 
> There's just one thing, avr-gcc/avr-g++ seem to produce stabs by
> default, it's not really useful to test with stabs nowadays.  I had a
> patch to make that board use dwarf by default (see below), but I never
> got around to try it properly and post it.  I'll try to do it soon (but
> you can apply it locally in the mean time).
> 
> Simon

Oh, and when running the test (with the dwarf patch applied), I hit an
internal error:


 92 (gdb) PASS: gdb.arch/avr-flash-qualifier.exp: print p
 93 backtrace 1^M
 94 #0  pass_to_function (p=0xe4 <data_in_flash> "\253") at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.arch/avr-flash-qualifier.c:23^M
 95 /home/simark/src/binutils-gdb/gdb/trad-frame.h:143: internal-error: LONGEST trad_frame_saved_reg::addr() const: Assertion `m_kind == trad_frame_saved_reg_    kind::ADDR' failed.^M

I'll try to bisect that, it might be a problem introduced by the
recent trad_frame changes (or the changes merely uncovered an existing
bug).


Simon


More information about the Gdb-patches mailing list