Re: [PATCH] gdb.dwarf2: Define and use gdb_target_symbol_prefix for symbol prefixes

Pedro Alves
2015-10-30T11:06:13Z

On 10/30/2015 04:25 AM, Kevin Buettner wrote:

> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 048070b..f8e35ac 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -5521,6 +5521,45 @@ proc core_find {binfile {deletefiles {}} {arg ""}} {
> return $destcore
> }
>
> +# gdb_target_symbol_prefix compiles a test program and uses readelf
> +# to determine the prefix (such as underscore) for linker symbol
> +# prefixes.
> +
> +proc gdb_target_symbol_prefix {} {

Shouldn't this be gdb_caching_proc ?

Then T wonder whether something like:

- DW_OP_addr table_2_ptr
+ DW_OP_addr [gdb_symbol table_2_ptr]

instead of prepending the $prefix variable results in clearer
test code.

> + set readelf_program [gdb_find_readelf]
> + set result [catch "exec $readelf_program --syms $exe" output]
> +
> + if { $result == 0 \
> + && ![regexp { ([^ a-zA-Z0-9]*)main$} $output dummy prefix] } {
> + verbose "gdb_target_symbol_prefix: Could not find main in readelf output; returning null prefix" 2
> + }

I'm wondering about using a method that would work for mingw/cygwin
as well. The only existing use of the target symbol prefix in the
tree is for those targets, which are coff/pe, not elf. See
gdb_target_symbol_prefix_flags. Maybe just use objdump instead?

Thanks,
Pedro Alves