[PATCH][gdb] Fix gdb.arch/amd64-tailcall-*.exp with -fPIE/-pie

Tom de Vries tdevries@suse.de
Fri Aug 9 15:03:00 GMT 2019


On 09-08-19 15:57, Pedro Alves wrote:
> On 8/9/19 11:48 AM, Tom de Vries wrote:
>> @@ -240,14 +242,38 @@ pretend_pc (struct frame_info *this_frame, struct tailcall_cache *cache)
>>    gdb_assert (next_levels >= 0);
>>  
>>    if (next_levels < chain->callees)
>> -    return chain->call_site[chain->length - next_levels - 1]->pc;
>> +    {
>> +      struct call_site *call_site
>> +	= chain->call_site[chain->length - next_levels - 1];
>> +      CORE_ADDR addr = call_site->pc;
>> +      struct dwarf2_per_objfile *dwarf2_per_objfile
>> +	= call_site->per_cu->dwarf2_per_objfile;
>> +       struct objfile *objfile = dwarf2_per_objfile->objfile;
>> +       CORE_ADDR baseaddr
>> +	 = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
>> +       struct gdbarch *gdbarch = get_objfile_arch (objfile);
>> +       addr = gdbarch_adjust_dwarf2_addr (gdbarch, addr + baseaddr);
>> +      return addr;
>> +    }
>>    next_levels -= chain->callees;
>>  
>>    /* Otherwise CHAIN->CALLEES are already covered by CHAIN->CALLERS.  */
>>    if (chain->callees != chain->length)
>>      {
>>        if (next_levels < chain->callers)
>> -	return chain->call_site[chain->callers - next_levels - 1]->pc;
>> +	{
>> +	  struct call_site *call_site
>> +	    = chain->call_site[chain->callers - next_levels - 1];
>> +	  CORE_ADDR addr = call_site->pc;
>> +	  struct dwarf2_per_objfile *dwarf2_per_objfile
>> +	    = call_site->per_cu->dwarf2_per_objfile;
>> +	  struct objfile *objfile = dwarf2_per_objfile->objfile;
>> +	  CORE_ADDR baseaddr
>> +	    = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
>> +	  struct gdbarch *gdbarch = get_objfile_arch (objfile);
>> +	  addr = gdbarch_adjust_dwarf2_addr (gdbarch, addr + baseaddr);
>> +	  return addr;
>> +	}
> 
> It seems like there's a repeated pattern here.  How about
> factoring out the common code to a function?

Indeed. How about this?

Thanks,
- Tom

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gdb-Fix-gdb.arch-amd64-tailcall-.exp-with-fPIE-pie.patch
Type: text/x-patch
Size: 3393 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20190809/bcc5733c/attachment.bin>


More information about the Gdb-patches mailing list