Message ID | 1433628336-24058-1-git-send-email-jcmvbkbc@gmail.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 107870 invoked by alias); 6 Jun 2015 22:06:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 107861 invoked by uid 89); 6 Jun 2015 22:06:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-la0-f42.google.com Received: from mail-la0-f42.google.com (HELO mail-la0-f42.google.com) (209.85.215.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 06 Jun 2015 22:06:02 +0000 Received: by laew7 with SMTP id w7so74133945lae.1 for <gdb-patches@sourceware.org>; Sat, 06 Jun 2015 15:05:59 -0700 (PDT) X-Received: by 10.112.140.9 with SMTP id rc9mr9557218lbb.14.1433628359537; Sat, 06 Jun 2015 15:05:59 -0700 (PDT) Received: from octofox.metropolis ([5.19.183.212]) by mx.google.com with ESMTPSA id ky7sm2868672lab.37.2015.06.06.15.05.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Jun 2015 15:05:58 -0700 (PDT) From: Max Filippov <jcmvbkbc@gmail.com> To: gdb-patches@sourceware.org Cc: Maxim Grigoriev <maxim2405@gmail.com>, Woody LaRue <larue@cadence.com>, Marc Gauthier <marc@cadence.com>, Max Filippov <jcmvbkbc@gmail.com> Subject: [PATCH] xtensa: initialize call_abi in xtensa_tdep Date: Sun, 7 Jun 2015 01:05:36 +0300 Message-Id: <1433628336-24058-1-git-send-email-jcmvbkbc@gmail.com> |
Commit Message
Max Filippov
June 6, 2015, 10:05 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. --- gdb/xtensa-tdep.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Sun, Jun 7, 2015 at 1:05 AM, Max Filippov <jcmvbkbc@gmail.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. > --- > gdb/xtensa-tdep.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h > index adacaf8..3b6ea66 100644 > --- a/gdb/xtensa-tdep.h > +++ b/gdb/xtensa-tdep.h > @@ -246,7 +246,8 @@ struct gdbarch_tdep > .spill_location = -1, \ > .spill_size = (spillsz), \ > .unused = 0, \ > - .call_abi = 0, \ > + .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, \ > -- Ping?
On Sun, Jun 07, 2015 at 01:05:36AM +0300, Max Filippov 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 am not sure I understand the patch. The first thing I should mention is that, unless what your patch suggests, the code as I see it on master currently initializes call_abi to CallAbiDefault: .call_abi = CallAbiDefault, \ And looking at the definitions of XSHAL_ABI and XTHAL_ABI_CALL0 in include/xtensa-config.h, those definitions seem to be entirely static... #undef XSHAL_ABI #undef XTHAL_ABI_WINDOWED #undef XTHAL_ABI_CALL0 #define XSHAL_ABI XTHAL_ABI_WINDOWED #define XTHAL_ABI_WINDOWED 0 #define XTHAL_ABI_CALL0 1 ... and resolving to distinct values. So the condition would always be false, resulting in call_abi always being set to CallAbiDefault. Am I missing something? > gdb/xtensa-tdep.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h > index adacaf8..3b6ea66 100644 > --- a/gdb/xtensa-tdep.h > +++ b/gdb/xtensa-tdep.h > @@ -246,7 +246,8 @@ struct gdbarch_tdep > .spill_location = -1, \ > .spill_size = (spillsz), \ > .unused = 0, \ > - .call_abi = 0, \ > + .call_abi = (XSHAL_ABI == XTHAL_ABI_CALL0) ? \ > + CallAbiCall0Only : CallAbiDefault, \ Small style issue: binary operators should be at the start of the next line, rather than the end of the current line. Also, for multi-line conditions like that, the GNU Coding Standard asks that we help automatic code formatters by wrapping the expression inside parentheses. These are redundant for the compiler, but help code formatters. Since the parens around the == operator are unecessary, I would have written the above: .call_abi = (XSHAL_ABI == XTHAL_ABI_CALL0 \ ? CallAbiCall0Only : CallAbiDefault), \ People sometime even write it as the following, finding it clearer (although a matter of taste, of course): .call_abi = (XSHAL_ABI == XTHAL_ABI_CALL0 \ ? CallAbiCall0Only \ : CallAbiDefault), \ I personally have no preference. > .debug_interrupt_level = XCHAL_DEBUGLEVEL, \ > .icache_line_bytes = XCHAL_ICACHE_LINESIZE, \ > .dcache_line_bytes = XCHAL_DCACHE_LINESIZE, \ > -- > 1.8.1.4
On Thu, Aug 20, 2015 at 3:09 PM, Joel Brobecker <brobecker@adacore.com> wrote: > On Sun, Jun 07, 2015 at 01:05:36AM +0300, Max Filippov 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 am not sure I understand the patch. > > The first thing I should mention is that, unless what your patch > suggests, the code as I see it on master currently initializes call_abi > to CallAbiDefault: > > .call_abi = CallAbiDefault, \ > > And looking at the definitions of XSHAL_ABI and XTHAL_ABI_CALL0 > in include/xtensa-config.h, those definitions seem to be entirely > static... > > #undef XSHAL_ABI > #undef XTHAL_ABI_WINDOWED > #undef XTHAL_ABI_CALL0 > #define XSHAL_ABI XTHAL_ABI_WINDOWED > #define XTHAL_ABI_WINDOWED 0 > #define XTHAL_ABI_CALL0 1 > > ... and resolving to distinct values. So the condition would always > be false, resulting in call_abi always being set to CallAbiDefault. > > Am I missing something? The file include/xtensa-config.h is meant to be replaced by processor-specific version where XSHAL_ABI definition may be different. That's why I mention 'call0 configuration' in the description: when xtensa core is configured without windowed registers it will necessarily have call0 ABI. >> gdb/xtensa-tdep.h | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h >> index adacaf8..3b6ea66 100644 >> --- a/gdb/xtensa-tdep.h >> +++ b/gdb/xtensa-tdep.h >> @@ -246,7 +246,8 @@ struct gdbarch_tdep >> .spill_location = -1, \ >> .spill_size = (spillsz), \ >> .unused = 0, \ >> - .call_abi = 0, \ >> + .call_abi = (XSHAL_ABI == XTHAL_ABI_CALL0) ? \ >> + CallAbiCall0Only : CallAbiDefault, \ > > Small style issue: binary operators should be at the start of > the next line, rather than the end of the current line. I'll send fixed v2.
> The file include/xtensa-config.h is meant to be replaced by > processor-specific version where XSHAL_ABI definition may be > different. That's why I mention 'call0 configuration' in the > description: when xtensa core is configured without > windowed registers it will necessarily have call0 ABI. This is the type of property that is normally dynamically determined. Is there a way to determine that info from the executable? That would be the proper way of fixing this issue.
On Thu, Aug 20, 2015 at 3:53 PM, Joel Brobecker <brobecker@adacore.com> wrote: >> The file include/xtensa-config.h is meant to be replaced by >> processor-specific version where XSHAL_ABI definition may be >> different. That's why I mention 'call0 configuration' in the >> description: when xtensa core is configured without >> windowed registers it will necessarily have call0 ABI. > > This is the type of property that is normally dynamically determined. > Is there a way to determine that info from the executable? That would > be the proper way of fixing this issue. I agree with that, but currently we can't distinguish executables with different call ABI.
diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h index adacaf8..3b6ea66 100644 --- a/gdb/xtensa-tdep.h +++ b/gdb/xtensa-tdep.h @@ -246,7 +246,8 @@ struct gdbarch_tdep .spill_location = -1, \ .spill_size = (spillsz), \ .unused = 0, \ - .call_abi = 0, \ + .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, \