numbers. Allow "foo2|selected stack frame".
* gdb.asm/asmsrc1.s: Use gdbasm_declare and gdbasm_end.
* gdb.asm/asmsrc2.s: Likewise.
* gdb.asm/common.inc: Define gdbasm_declare and gdbasm_end. Update
comments.
* gdb.asm/mips.inc: New file.
if [istarget "m32r*-*"] then {
set asm-arch m32r
}
+if [istarget "mips*-*"] then {
+ set asm-arch mips
+}
if [istarget "powerpc*-*"] then {
set asm-arch powerpc
}
# Now try a source file search
gdb_test "search A routine for foo2 to call" \
- "39\[ \t\]+comment \"A routine for foo2 to call.\"" "search"
+ "40\[ \t\]+comment \"A routine for foo2 to call.\"" "search"
# See if `f' prints the right source file.
gdb_test "f" ".*asmsrc2\[.\]s:8.*" "f in foo2"
gdb_test "n" "" "n 2"
# Now see if a capped `bt' is correct.
-gdb_test "bt 3" "\#0.*foo3.*asmsrc1\[.\]s:44.*\#1.*foo2.*asmsrc2\[.\]s:12.*\#2.*main.*asmsrc1\[.\]s:33.*" "bt 3 in foo3"
+gdb_test "bt 3" "\#0.*foo3.*asmsrc1\[.\]s:45.*\#1.*foo2.*asmsrc2\[.\]s:12.*\#2.*main.*asmsrc1\[.\]s:33.*" "bt 3 in foo3"
# Try 'info source' from asmsrc1.s
gdb_test "info source" \
# Try 'return' from foo2
gdb_test "return" "\#0 main .*37\[ \t\]+gdbasm_exit0" "return from foo2" \
- "Make selected stack frame return now\?.*" "y"
+ "Make (foo2|selected stack frame) return now\?.*" "y"
# See if we can look at a global variable
gdb_test "print globalvar" ".* = 11" "look at global variable"
comment "Provide very simplistic equivalent."
.global _start
-_start:
+gdbasm_declare _start
gdbasm_startup
gdbasm_call main
gdbasm_exit0
-
+ gdbasm_end _start
comment "main routine for assembly source debugging test"
comment "This particular testcase uses macros in <arch>.inc to achieve"
comment "machine independence."
.global main
-main:
+gdbasm_declare main
gdbasm_enter
comment "Call a macro that consists of several lines of assembler code."
comment "All done."
gdbasm_exit0
+ gdbasm_end main
comment "A routine for foo2 to call."
.global foo3
-foo3:
+gdbasm_declare foo3
gdbasm_enter
gdbasm_leave
+ gdbasm_end foo3
.global exit
-exit:
+gdbasm_declare exit
gdbasm_exit0
+ gdbasm_end exit
comment "A static function"
-foostatic:
+gdbasm_declare foostatic
gdbasm_enter
gdbasm_leave
+ gdbasm_end foostatic
comment "A global variable"
comment "Second file in assembly source debugging testcase."
.global foo2
-foo2:
+gdbasm_declare foo2
gdbasm_enter
comment "Call someplace else (several times)."
comment "All done, return."
gdbasm_leave
+ gdbasm_end foo2
.word \value
.endm
+ comment "Declare a subroutine"
+ .macro gdbasm_declare name
+\name:
+ .endm
+
+ comment "End a subroutine"
+ .macro gdbasm_end name
+ .endm
+
comment "arch.inc is responsible for defining the following macros:"
comment "enter - subroutine prologue"
comment "leave - subroutine epilogue"
comment "arch.inc may also override the default definitions of:"
comment "datavar - define a data variable"
-
-comment "macros to label a subroutine may also eventually be needed"
-comment "i.e. .global foo\nfoo:\n"
+comment "declare - declare the start of a subroutine"
+comment "end - end a subroutine"
--- /dev/null
+ comment "subroutine declare"
+ .macro gdbasm_declare name
+ .align 2
+ .ent \name
+ .type \name,@function
+\name:
+ .endm
+
+ comment "subroutine prologue"
+ .macro gdbasm_enter
+ .frame $fp, 32, $31
+ .mask 0xd0000000,-4
+ .set noreorder
+ .cpload $25
+ .set reorder
+ subu $sp, $sp, 32
+ .cprestore 16
+ sw $31, 28($sp)
+ sw $fp, 24($sp)
+ sw $28, 20($sp)
+ move $fp, $sp
+ .endm
+
+ comment "subroutine epilogue"
+ .macro gdbasm_leave
+ lw $31, 28($sp)
+ lw $fp, 24($sp)
+ .set noreorder
+ .set nomacro
+ j $31
+ addu $sp, $sp, 32
+ .set macro
+ .set reorder
+ .endm
+
+ comment "subroutine end"
+ .macro gdbasm_end name
+ .end \name
+ .endm
+
+ .macro gdbasm_call subr
+ la $25, \subr
+ jal $31, $25
+ .endm
+
+ .macro gdbasm_several_nops
+ nop
+ nop
+ nop
+ nop
+ .endm
+
+ comment "exit (0)"
+ .macro gdbasm_exit0
+ comment "Don't know how to exit, but this will certainly halt..."
+ lw $2, 0($0)
+ .endm
+
+ comment "crt0 startup"
+ .macro gdbasm_startup
+ .global __start
+__start:
+ move $fp, $sp
+ .endm