From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Snyder To: gdb-patches@sources.redhat.com Cc: cagney@redhat.com, fnasser@redhat.com Subject: [RFA] More testing for assembly language source debugging Date: Fri, 30 Nov 2001 17:18:00 -0000 Message-ID: <200112010116.fB11GDQ29121@reddwarf.cygnus.com> X-SW-Source: 2001-11/msg00641.html Message-ID: <20011130171800.8tLpjJDUhPxcfTbgboaZ73tpDCwXWpmkRBqQey9U55A@z> This is an enhancement to the existing test 'asm-source.exp'. I have added tests for list, search, finish, return, next, info line, info source, info sources, static functions, and global and static variables. A new macro has been added to 'common.inc' for declaring a variable. By default it uses ".word", but it can be overridden in the arch.inc file if .word does not correspond to the default size of an integer, or if different syntax, different alignment etc. is required. This was the case for i386, so i386.inc has an overriding definition for this macro. These tests exposed some failures in the D10V, so I had to whack on d10v.inc to make it set up a more robust stack structure. 2001-11-30 Michael Snyder * gdb.asm/asm-source.exp: Add tests for list, search, finish, return, next, info source, info sources, info line, global and static variables, and static functions. * gdb.asm/common.inc: New macro gdbasm_datavar (default definition). * gdb.asm/i386.inc: Override default definition of gdbasm_datavar. * gdb.asm/asmsrc1.s: Add a static function and some variables. * gdb.asm/asmsrc2.s: Make foo2 call foo3 twice (to test 'next'). * gdb.asm/d10v.inc (gdbasm_enter): Set up frame pointer. (gdbasm_leave): Restore frame pointer. (gdbasm_startup): Copy stack set-up from crt0.S. Index: i386.inc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/i386.inc,v retrieving revision 1.1 diff -c -3 -p -r1.1 i386.inc *** i386.inc 2001/11/22 01:07:24 1.1 --- i386.inc 2001/12/01 00:55:16 *************** *** 30,32 **** --- 30,39 ---- .macro gdbasm_startup xor %ebp, %ebp .endm + + comment "Declare a data variable" + .macro gdbasm_datavar name value + .data + \name: + .long \value + .endm Index: d10v.inc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/d10v.inc,v retrieving revision 1.3 diff -c -3 -p -r1.3 d10v.inc *** d10v.inc 2001/11/10 17:55:48 1.3 --- d10v.inc 2001/12/01 00:55:16 *************** *** 1,12 **** comment "subroutine prologue" .macro gdbasm_enter st r13,@-sp .endm comment "subroutine epilogue" .macro gdbasm_leave ! ld r13,@sp+ ! jmp r13 .endm .macro gdbasm_call subr --- 1,16 ---- comment "subroutine prologue" .macro gdbasm_enter + st r11,@-sp st r13,@-sp + mv r11,sp .endm comment "subroutine epilogue" .macro gdbasm_leave ! add3 sp,r11,0 ! ld r13,@sp+ ! ld r11,@sp+ ! jmp r13 .endm .macro gdbasm_call subr *************** *** 29,32 **** --- 33,55 ---- comment "crt0 startup" .macro gdbasm_startup + ; R14 always contains memory base address (0) + + ldi r14,0 + + ; Set the USER and SYSTEM stack pointers. + + ldi r0, 0 ; zero arguments + ldi r1, 0 + mvtc r0, psw ; select SPI and set it + ldi sp, _stack + ldi r10, 0x8000 ; select SPU/FP and set it + mvtc r10, psw || ldi r11, 0; clear stack frame + ldi sp, _stack - 0x200 + ldi r13, 0 + + st r11, @-sp + st r13, @-sp + ; mv r11, sp + .endm Index: common.inc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/common.inc,v retrieving revision 1.1.1.1 diff -c -3 -p -r1.1.1.1 common.inc *** common.inc 1999/04/16 01:34:30 1.1.1.1 --- common.inc 2001/12/01 00:55:16 *************** *** 7,18 **** --- 7,28 ---- .include "\arch\file" .endm + comment "Declare a data variable" + .macro gdbasm_datavar name value + .data + \name: + .word \value + .endm + comment "arch.inc is responsible for defining the following macros:" comment "enter - subroutine prologue" comment "leave - subroutine epilogue" comment "call - call a named subroutine" comment "several_nops - execute several (typically 4) nops" comment "exit0 - exit (0)" + + 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" Index: asmsrc1.s =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asmsrc1.s,v retrieving revision 1.3 diff -c -3 -p -r1.3 asmsrc1.s *** asmsrc1.s 2001/11/10 17:55:48 1.3 --- asmsrc1.s 2001/12/01 00:55:16 *************** foo3: *** 46,48 **** --- 46,63 ---- .global exit exit: gdbasm_exit0 + + comment "A static function" + + foostatic: + gdbasm_enter + gdbasm_leave + + comment "A global variable" + + .global globalvar + gdbasm_datavar globalvar 11 + + comment "A static variable" + + gdbasm_datavar staticvar 5 Index: asmsrc2.s =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asmsrc2.s,v retrieving revision 1.2 diff -c -3 -p -r1.2 asmsrc2.s *** asmsrc2.s 2001/11/10 17:55:48 1.2 --- asmsrc2.s 2001/12/01 00:55:16 *************** comment "Second file in assembly source *** 7,14 **** foo2: gdbasm_enter ! comment "Call someplace else." gdbasm_call foo3 comment "All done, return." --- 7,15 ---- foo2: gdbasm_enter ! comment "Call someplace else (several times)." + gdbasm_call foo3 gdbasm_call foo3 comment "All done, return." Index: asm-source.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.asm/asm-source.exp,v retrieving revision 1.9 diff -c -3 -p -r1.9 asm-source.exp *** asm-source.exp 2001/11/27 01:29:03 1.9 --- asm-source.exp 2001/12/01 00:55:16 *************** gdb_test "n" "33\[ \]*.*foo2" "next ove *** 96,101 **** --- 96,108 ---- # See if we can properly `step' into a subroutine call. gdb_test "s" "8\[ \]*.*" "step into foo2" + # Now try a 'list' from the other source file. + gdb_test "list _start" ".*gdbasm_startup.*" "list" + + # 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" + # See if `f' prints the right source file. gdb_test "f" ".*asmsrc2\[.\]s:8.*" "f in foo2" *************** gdb_test "n" "" "n 2" *** 120,122 **** --- 127,171 ---- # 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" + + # Try 'info source' from asmsrc1.s + gdb_test "info source" \ + "Current source file is .*asmsrc1.s.*Source language is asm.*" \ + "info source asmsrc1.s" + + # Try 'finishing' from foo3 + gdb_test "finish" "Run till exit from.*\[\r\n\]13\[ \t\]+gdbasm_call foo3" \ + "finish from foo3" + + # Try 'info source' from asmsrc2.s + gdb_test "info source" \ + "Current source file is .*asmsrc2.s.*Source language is asm.*" \ + "info source asmsrc2.s" + + # Try 'info sources' + gdb_test "info sources" \ + "Source files .*asmsrc\[12\].s.*asmsrc\[12\].s.*" \ + "info sources" + + # Try 'info line' + gdb_test "info line" \ + "Line 13 of.*asmsrc2.s.*starts at.* and ends at.*." \ + "info line" + + # Try 'nexting' over next call to foo3 + gdb_test "next" "17\[ \t\]+gdbasm_leave" "next over foo3" + + # Try 'return' from foo2 + gdb_test "return" "\#0 main .*37\[ \t\]+gdbasm_exit0" "return from foo2" \ + "Make selected stack frame return now\?.*" "y" + + # See if we can look at a global variable + gdb_test "print globalvar" ".* = 11" "look at global variable" + + # See if we can look at a static variable + gdb_test "print staticvar" ".* = 5" "look at static variable" + + # See if we can look at a static function + gdb_test "disassem foostatic" ".*:.*End of assembler dump." \ + "look at static function" +