* [SH] gdb.asm/asm-source.exp
@ 2012-03-22 17:40 Thomas Schwinge
2012-03-23 3:56 ` Kevin Buettner
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Schwinge @ 2012-03-22 17:40 UTC (permalink / raw)
To: gdb-patches; +Cc: Kevin Buettner
[-- Attachment #1: Type: text/plain, Size: 4845 bytes --]
Hi!
On SH, gdb.asm/asm-source.exp currently fails to build as follows:
Executing on host: sh-linux-gnu-as [...]/gdb/testsuite/gdb.asm/asmsrc1.s -I[...]/gdb/testsuite/gdb.asm -I[...]/gdb.d/gdb.asm -gdwarf2 -o asmsrc1.o (timeout = 3600)
[GDB]/gdb/testsuite/gdb.asm/asmsrc1.s: Assembler messages:
[GDB]/gdb/testsuite/gdb.asm/asmsrc1.s: Error: .size expression for _start does not evaluate to a constant
[GDB]/gdb/testsuite/gdb.asm/asmsrc1.s: Error: .size expression for main does not evaluate to a constant
[GDB]/gdb/testsuite/gdb.asm/asmsrc1.s: Error: .size expression for foo3 does not evaluate to a constant
[GDB]/gdb/testsuite/gdb.asm/asmsrc1.s: Error: .size expression for exit does not evaluate to a constant
[GDB]/gdb/testsuite/gdb.asm/asmsrc1.s: Error: .size expression for foostatic does not evaluate to a constant
assembler exited with status 1
This comes from gdb.asm/sh.inc:
31 comment "subroutine end"
32 .purgem gdbasm_end
33 .macro gdbasm_end name
34 .size \name, .-_foo1
35 .align 1
36 .endm
The _foo1 symbol doesn't exist anywhere (and it never has, in gdb.asm's
lifetime). This is easily fixed, and makes the tests PASS for sh-elf.
(As this code has never been touched since its initial commit in 2003, I
wonder for how long this has been broken -- probably ever since? Or what
were earlier assembler versions able to make out of that?)
gdb/testsuite/
* gdb.asm/sh.inc (gdbasm_end) <.size>: Refer to the function's name.
Index: gdb.asm/sh.inc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/sh.inc,v
retrieving revision 1.2
diff -u -p -r1.2 sh.inc
--- gdb.asm/sh.inc 7 Mar 2005 21:16:50 -0000 1.2
+++ gdb.asm/sh.inc 22 Mar 2012 17:27:40 -0000
@@ -31,7 +31,7 @@
comment "subroutine end"
.purgem gdbasm_end
.macro gdbasm_end name
- .size \name, .-_foo1
+ .size \name, . - \name
.align 1
.endm
However, that is not enough to make the executable runnable on
sh-linux-gnu: it chokes due to the stack pointer setup in gdbasm_startup.
There are several ways to address this (see ``diff -u m32r.inc
m32r-linux.inc'' for one example); I chose to generalize the code as
follows:
gdb/testsuite/
* gdb.asm/sh.inc (gdbasm_startup): Only set up the stack pointer if the
symbol _stack is defined. Get rid of a hard-coded constant for _stack.
Index: gdb.asm/sh.inc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/sh.inc,v
retrieving revision 1.2
diff -u -p -r1.2 sh.inc
--- gdb.asm/sh.inc 7 Mar 2005 21:16:50 -0000 1.2
+++ gdb.asm/sh.inc 22 Mar 2012 17:27:40 -0000
@@ -65,13 +65,19 @@
comment "crt0 startup"
.macro gdbasm_startup
- mov.l .stackaddr,r15
+ comment "If there is a _stack symbol, use it for setting up the stack"
+ comment "pointer. In hosted mode (when there is no _stack symbol),"
+ comment "the operating system will have initialized it already."
+ mov.l .stackaddr, r0
+ tst r0, r0
+ bt .afterstackaddr
+ mov r0, r15
bra .afterstackaddr
nop
- nop
.align 2
.stackaddr:
- .long 196608 ! 0x30000
+ .weak _stack
+ .long _stack
.align 1
.afterstackaddr:
.endm
Now the tests all PASS for both sh-linux-gnu and sh-elf:
PASS: gdb.asm/asm-source.exp: f at main
PASS: gdb.asm/asm-source.exp: next over macro
PASS: gdb.asm/asm-source.exp: step into foo2
PASS: gdb.asm/asm-source.exp: info target
PASS: gdb.asm/asm-source.exp: info symbol
PASS: gdb.asm/asm-source.exp: list
PASS: gdb.asm/asm-source.exp: search
PASS: gdb.asm/asm-source.exp: f in foo2
PASS: gdb.asm/asm-source.exp: n in foo2
PASS: gdb.asm/asm-source.exp: bt ALL in foo2
PASS: gdb.asm/asm-source.exp: bt 2 in foo2
PASS: gdb.asm/asm-source.exp: s 2
PASS: gdb.asm/asm-source.exp: n 2
PASS: gdb.asm/asm-source.exp: bt 3 in foo3
PASS: gdb.asm/asm-source.exp: info source asmsrc1.s
PASS: gdb.asm/asm-source.exp: finish from foo3
PASS: gdb.asm/asm-source.exp: info source asmsrc2.s
PASS: gdb.asm/asm-source.exp: info sources
PASS: gdb.asm/asm-source.exp: info line
PASS: gdb.asm/asm-source.exp: next over foo3
PASS: gdb.asm/asm-source.exp: return from foo2
PASS: gdb.asm/asm-source.exp: look at global variable
PASS: gdb.asm/asm-source.exp: x/i &globalvar
PASS: gdb.asm/asm-source.exp: disassem &globalvar, &globalvar+1
PASS: gdb.asm/asm-source.exp: look at static variable
PASS: gdb.asm/asm-source.exp: x/i &staticvar
PASS: gdb.asm/asm-source.exp: disassem &staticvar, &staticvar+1
PASS: gdb.asm/asm-source.exp: look at static function
OK to commit both patches?
Grüße,
Thomas
[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [SH] gdb.asm/asm-source.exp
2012-03-22 17:40 [SH] gdb.asm/asm-source.exp Thomas Schwinge
@ 2012-03-23 3:56 ` Kevin Buettner
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Buettner @ 2012-03-23 3:56 UTC (permalink / raw)
To: gdb-patches
Hi Thomas,
On Thu, 22 Mar 2012 18:40:03 +0100
Thomas Schwinge <thomas_schwinge@mentor.com> wrote:
> gdb/testsuite/
>
> * gdb.asm/sh.inc (gdbasm_end) <.size>: Refer to the function's name.
[...]
> gdb/testsuite/
>
> * gdb.asm/sh.inc (gdbasm_startup): Only set up the stack pointer if the
> symbol _stack is defined. Get rid of a hard-coded constant for _stack.
[...]
>
> OK to commit both patches?
I'm not an expert on this stuff, but your patches look reasonable to
me. Please wait a few days for objections and, if none are
forthcoming, check it in.
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-23 3:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-22 17:40 [SH] gdb.asm/asm-source.exp Thomas Schwinge
2012-03-23 3:56 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox