[v3] xtensa: initialize call_abi in xtensa_tdep

Message ID 1440078815-14369-1-git-send-email-jcmvbkbc@gmail.com
State New, archived
Headers

Commit Message

Max Filippov Aug. 20, 2015, 1:53 p.m. UTC
  Use XSHAL_ABI value provided by xtensa-config.h to correctly initialize
xtensa_tdep.call_abi
This fixes calls to functions from GDB that otherwise fail with the
following assertion in call0 configuration:

  gdb/regcache.c:602: internal-error: regcache_raw_read: Assertion
  `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.

gdb/
	* xtensa-tdep.h (XTENSA_GDBARCH_TDEP_INSTANTIATE): Initialize
	call_abi using XSHAL_ABI macro.
---
Changes v2 -> v3:
- rebase to the current master.

Changes v1 -> v2:
- fix call_abi code formatting.

 gdb/xtensa-tdep.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Joel Brobecker Aug. 28, 2015, 12:37 a.m. UTC | #1
> Use XSHAL_ABI value provided by xtensa-config.h to correctly initialize
> xtensa_tdep.call_abi
> This fixes calls to functions from GDB that otherwise fail with the
> following assertion in call0 configuration:
> 
>   gdb/regcache.c:602: internal-error: regcache_raw_read: Assertion
>   `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.
> 
> gdb/
> 	* xtensa-tdep.h (XTENSA_GDBARCH_TDEP_INSTANTIATE): Initialize
> 	call_abi using XSHAL_ABI macro.

I may have missed the end of the discussion about how to properly
build for your target. But, in the meantime, I don't think your patch
is amking things all that worse, and perhaps even easier for others
to have a functional GDB, so the patch is OK with me. Pedro, please
yell if you think I'm wrong to approve.

> ---
> Changes v2 -> v3:
> - rebase to the current master.
> 
> Changes v1 -> v2:
> - fix call_abi code formatting.
> 
>  gdb/xtensa-tdep.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
> index caa2988..ff090f3 100644
> --- a/gdb/xtensa-tdep.h
> +++ b/gdb/xtensa-tdep.h
> @@ -246,7 +246,9 @@ struct gdbarch_tdep
>  	  .spill_location = -1,					\
>  	  .spill_size = (spillsz),				\
>  	  .unused = 0,						\
> -	  .call_abi = CallAbiDefault,				\
> +	  .call_abi = (XSHAL_ABI == XTHAL_ABI_CALL0		\
> +		       ? CallAbiCall0Only			\
> +		       : CallAbiDefault),			\
>  	  .debug_interrupt_level = XCHAL_DEBUGLEVEL,		\
>  	  .icache_line_bytes = XCHAL_ICACHE_LINESIZE,		\
>  	  .dcache_line_bytes = XCHAL_DCACHE_LINESIZE,		\
> -- 
> 1.8.1.4
  
Max Filippov Aug. 31, 2015, 9:03 a.m. UTC | #2
On Fri, Aug 28, 2015 at 3:37 AM, Joel Brobecker <brobecker@adacore.com> wrote:
>> Use XSHAL_ABI value provided by xtensa-config.h to correctly initialize
>> xtensa_tdep.call_abi
>> This fixes calls to functions from GDB that otherwise fail with the
>> following assertion in call0 configuration:
>>
>>   gdb/regcache.c:602: internal-error: regcache_raw_read: Assertion
>>   `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.
>>
>> gdb/
>>       * xtensa-tdep.h (XTENSA_GDBARCH_TDEP_INSTANTIATE): Initialize
>>       call_abi using XSHAL_ABI macro.
>
> I may have missed the end of the discussion about how to properly
> build for your target. But, in the meantime, I don't think your patch
> is amking things all that worse, and perhaps even easier for others
> to have a functional GDB, so the patch is OK with me. Pedro, please
> yell if you think I'm wrong to approve.

I've committed this patch to master. Thanks!

-- Max
  

Patch

diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
index caa2988..ff090f3 100644
--- a/gdb/xtensa-tdep.h
+++ b/gdb/xtensa-tdep.h
@@ -246,7 +246,9 @@  struct gdbarch_tdep
 	  .spill_location = -1,					\
 	  .spill_size = (spillsz),				\
 	  .unused = 0,						\
-	  .call_abi = CallAbiDefault,				\
+	  .call_abi = (XSHAL_ABI == XTHAL_ABI_CALL0		\
+		       ? CallAbiCall0Only			\
+		       : CallAbiDefault),			\
 	  .debug_interrupt_level = XCHAL_DEBUGLEVEL,		\
 	  .icache_line_bytes = XCHAL_ICACHE_LINESIZE,		\
 	  .dcache_line_bytes = XCHAL_DCACHE_LINESIZE,		\