diff options
author | Pedro Alves <palves@redhat.com> | 2011-03-18 18:51:08 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-03-18 18:51:08 +0000 |
commit | 8661b11b1820e3cc09a19c9ac0b195d18f2f8638 (patch) | |
tree | 2010673ad61df05aa5678f21b270ae36d783a63a /gdb | |
parent | f23d1b929daf1f1513c63ac810f05db9b1492c10 (diff) | |
download | binutils-8661b11b1820e3cc09a19c9ac0b195d18f2f8638.tar.gz binutils-8661b11b1820e3cc09a19c9ac0b195d18f2f8638.tar.bz2 binutils-8661b11b1820e3cc09a19c9ac0b195d18f2f8638.zip |
gdb/testsuite/
* gdb.trace/unavailable.cc (args_test_func, local_test_func)
(reglocal_test_func, statlocal_test_func): New functions.
(globals_test_func): Call new functions.
* gdb.trace/unavailable.exp (gdb_collect_args_test)
(gdb_collect_locals_test): New procedure.
(gdb_trace_collection_test): Call new procedures.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/testsuite/gdb.trace/unavailable.cc | 126 | ||||
-rw-r--r-- | gdb/testsuite/gdb.trace/unavailable.exp | 131 |
3 files changed, 266 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 77bad9fb738..2abb0f9825c 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,14 @@ 2011-03-18 Pedro Alves <pedro@codesourcery.com> + * gdb.trace/unavailable.cc (args_test_func, local_test_func) + (reglocal_test_func, statlocal_test_func): New functions. + (globals_test_func): Call new functions. + * gdb.trace/unavailable.exp (gdb_collect_args_test) + (gdb_collect_locals_test): New procedure. + (gdb_trace_collection_test): Call new procedures. + +2011-03-18 Pedro Alves <pedro@codesourcery.com> + * gdb.trace/unavailable.exp (fpreg, spreg, pcreg): Define. (test_register, test_register_unavailable): New procedures. (gdb_unavailable_registers_test): New procedure. diff --git a/gdb/testsuite/gdb.trace/unavailable.cc b/gdb/testsuite/gdb.trace/unavailable.cc index 36b74556677..12b0b2526da 100644 --- a/gdb/testsuite/gdb.trace/unavailable.cc +++ b/gdb/testsuite/gdb.trace/unavailable.cc @@ -184,6 +184,128 @@ end () /* called after everything else */ { } +/* Test (not) collecting args. */ + +int +args_test_func (char argc, + int argi, + float argf, + double argd, + test_struct argstruct, + int argarray[4]) +{ + int i; + + i = (int) argc + argi + argf + argd + argstruct.memberi + argarray[1]; + + return i; +} + +/* Test (not) collecting array args. */ + +/* Test (not) collecting locals. */ + +int +local_test_func () +{ + char locc = 11; + int loci = 12; + float locf = 13.3; + double locd = 14.4; + test_struct locst; + int locar[4]; + int i; + struct localstruct {} locdefst; + + locst.memberc = 15; + locst.memberi = 16; + locst.memberf = 17.7; + locst.memberd = 18.8; + locar[0] = 121; + locar[1] = 122; + locar[2] = 123; + locar[3] = 124; + + i = /* set local_test_func tracepoint here */ + (int) locc + loci + locf + locd + locst.memberi + locar[1]; + + return i; +} + +/* Test collecting register locals. */ + +int +reglocal_test_func () +{ + register char locc = 11; + register int loci = 12; + register float locf = 13.3; + register double locd = 14.4; + register test_struct locst; + register int locar[4]; + int i; + + locst.memberc = 15; + locst.memberi = 16; + locst.memberf = 17.7; + locst.memberd = 18.8; + locar[0] = 121; + locar[1] = 122; + locar[2] = 123; + locar[3] = 124; + + i = /* set reglocal_test_func tracepoint here */ + (int) locc + loci + locf + locd + locst.memberi + locar[1]; + + return i; +} + +/* Test collecting static locals. */ + +int +statlocal_test_func () +{ + static char locc; + static int loci; + static float locf; + static double locd; + static test_struct locst; + static int locar[4]; + int i; + + locc = 11; + loci = 12; + locf = 13.3; + locd = 14.4; + locst.memberc = 15; + locst.memberi = 16; + locst.memberf = 17.7; + locst.memberd = 18.8; + locar[0] = 121; + locar[1] = 122; + locar[2] = 123; + locar[3] = 124; + + i = /* set statlocal_test_func tracepoint here */ + (int) locc + loci + locf + locd + locst.memberi + locar[1]; + + /* Set static locals back to zero so collected values are clearly special. */ + locc = 0; + loci = 0; + locf = 0; + locd = 0; + locst.memberc = 0; + locst.memberi = 0; + locst.memberf = 0; + locst.memberd = 0; + locar[0] = 0; + locar[1] = 0; + locar[2] = 0; + locar[3] = 0; + + return i; +} + int globals_test_func () { @@ -239,6 +361,10 @@ main (int argc, char **argv, char **envp) /* Call test functions, so they can be traced and data collected. */ i = 0; + i += args_test_func (1, 2, 3.3, 4.4, mystruct, myarray); + i += local_test_func (); + i += reglocal_test_func (); + i += statlocal_test_func (); i += globals_test_func (); /* Set 'em back to zero, so that the collected values will be diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp index f526ac30fc7..4840e2b2b56 100644 --- a/gdb/testsuite/gdb.trace/unavailable.exp +++ b/gdb/testsuite/gdb.trace/unavailable.exp @@ -107,6 +107,132 @@ proc run_trace_experiment { test_func } { # Test procs # +proc gdb_collect_args_test {} { + global cr + global gdb_prompt + global pf_prefix + + set old_pf_prefix $pf_prefix + set pf_prefix "$pf_prefix unavailable arguments:" + + prepare_for_trace_test + + gdb_test "trace args_test_func" \ + "Tracepoint \[0-9\]+ at .*" \ + "set tracepoint" + + # Begin the test. + run_trace_experiment args_test_func + + # Test printing the variables, and also their addresses. We + # haven't collected any stack, so there's no way GDB can figure + # out the latter. + + gdb_test "print argc" " = <unavailable>" + gdb_test "print &argc" \ + "Can't take address of \"argc\" which isn't an lvalue\." + + gdb_test "print argi" " = <unavailable>" + gdb_test "print &argi" \ + "Can't take address of \"argi\" which isn't an lvalue\." + + gdb_test "print argf" " = <unavailable>" + gdb_test "print &argf" \ + "Can't take address of \"argf\" which isn't an lvalue\." + + gdb_test "print argd" " = <unavailable>" + gdb_test "print &argd" \ + "Can't take address of \"argd\" which isn't an lvalue\." + + # struct arg as one of several args (near end of list) + + gdb_test "print argstruct" \ + " = \{memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>\}" + + gdb_test "print argstruct.memberc" " = <unavailable>" + gdb_test "print argstruct.memberi" " = <unavailable>" + gdb_test "print argstruct.memberf" " = <unavailable>" + gdb_test "print argstruct.memberd" " = <unavailable>" + + gdb_test "print argarray" " = \\(int \\*\\) <unavailable>" + + gdb_test "print &argarray" \ + "Can't take address of \"argarray\" which isn't an lvalue\." + + gdb_test "print argarray\[0\]" "value is not available" + + # Test "info args" + set r "" + set r "${r}argc = <unavailable>${cr}" + set r "${r}argi = <unavailable>${cr}" + set r "${r}argf = <unavailable>${cr}" + set r "${r}argd = <unavailable>${cr}" + set r "${r}argstruct = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}" + set r "${r}argarray = <unavailable>${cr}" + gdb_test "info args" "$r" "info args" + + gdb_test "tfind none" \ + "#0 end .*" \ + "cease trace debugging" + + set pf_prefix $old_pf_prefix +} + +proc gdb_collect_locals_test { func msg } { + global cr + global gdb_prompt + global pf_prefix + + set old_pf_prefix $pf_prefix + set pf_prefix "$pf_prefix unavailable locals: $msg:" + + prepare_for_trace_test + + set testline [gdb_get_line_number "set $func tracepoint here"] + + gdb_test "trace $testline" \ + "Tracepoint \[0-9\]+ at .*" \ + "set tracepoint" + + # Begin the test. + run_trace_experiment $func + + gdb_test "print locc" " = <unavailable>" + gdb_test "print loci" " = <unavailable>" + gdb_test "print locf" " = <unavailable>" + gdb_test "print locd" " = <unavailable>" + + gdb_test "print locst.memberc" " = <unavailable>" + gdb_test "print locst.memberi" " = <unavailable>" + gdb_test "print locst.memberf" " = <unavailable>" + gdb_test "print locst.memberd" " = <unavailable>" + + gdb_test "print locar\[0\]" " = <unavailable>" + gdb_test "print locar\[1\]" " = <unavailable>" + gdb_test "print locar\[2\]" " = <unavailable>" + gdb_test "print locar\[3\]" " = <unavailable>" + + # Test "info locals" + set r "" + set r "${r}locf = <unavailable>${cr}" + set r "${r}locd = <unavailable>${cr}" + set r "${r}locst = {memberc = <unavailable>, memberi = <unavailable>, memberf = <unavailable>, memberd = <unavailable>}${cr}" + set r "${r}locar = {<unavailable>, <unavailable>, <unavailable>, <unavailable>}${cr}" + set r "${r}i = <unavailable>${cr}" + if { $func == "local_test_func" } { + set r "${r}locdefst = {<No data fields>}${cr}" + } + set r "${r}locc = <unavailable>${cr}" + set r "${r}loci = <unavailable>${cr}" + gdb_test "info locals" "$r" "info locals" + + gdb_test "tfind none" \ + "#0 end .*" \ + "cease trace debugging" + + set pf_prefix $old_pf_prefix +} + proc gdb_unavailable_registers_test { } { global gdb_prompt global spreg @@ -417,6 +543,11 @@ proc gdb_collect_globals_test { } { proc gdb_trace_collection_test {} { gdb_collect_globals_test gdb_unavailable_registers_test + + gdb_collect_args_test + gdb_collect_locals_test local_test_func "auto locals" + gdb_collect_locals_test reglocal_test_func "register locals" + gdb_collect_locals_test statlocal_test_func "static locals" } clean_restart $executable |