From 8661b11b1820e3cc09a19c9ac0b195d18f2f8638 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 18 Mar 2011 18:51:08 +0000 Subject: [PATCH] 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. --- gdb/testsuite/ChangeLog | 9 +++ gdb/testsuite/gdb.trace/unavailable.cc | 126 ++++++++++++++++++++++++++++++ gdb/testsuite/gdb.trace/unavailable.exp | 131 ++++++++++++++++++++++++++++++++ 3 files changed, 266 insertions(+) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 77bad9f..2abb0f9 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,14 @@ 2011-03-18 Pedro Alves + * 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 + * 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 36b7455..12b0b25 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 f526ac3..4840e2b 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" " = " + gdb_test "print &argc" \ + "Can't take address of \"argc\" which isn't an lvalue\." + + gdb_test "print argi" " = " + gdb_test "print &argi" \ + "Can't take address of \"argi\" which isn't an lvalue\." + + gdb_test "print argf" " = " + gdb_test "print &argf" \ + "Can't take address of \"argf\" which isn't an lvalue\." + + gdb_test "print argd" " = " + 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 = , memberi = , memberf = , memberd = \}" + + gdb_test "print argstruct.memberc" " = " + gdb_test "print argstruct.memberi" " = " + gdb_test "print argstruct.memberf" " = " + gdb_test "print argstruct.memberd" " = " + + gdb_test "print argarray" " = \\(int \\*\\) " + + 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 = ${cr}" + set r "${r}argi = ${cr}" + set r "${r}argf = ${cr}" + set r "${r}argd = ${cr}" + set r "${r}argstruct = {memberc = , memberi = , memberf = , memberd = }${cr}" + set r "${r}argarray = ${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" " = " + gdb_test "print loci" " = " + gdb_test "print locf" " = " + gdb_test "print locd" " = " + + gdb_test "print locst.memberc" " = " + gdb_test "print locst.memberi" " = " + gdb_test "print locst.memberf" " = " + gdb_test "print locst.memberd" " = " + + gdb_test "print locar\[0\]" " = " + gdb_test "print locar\[1\]" " = " + gdb_test "print locar\[2\]" " = " + gdb_test "print locar\[3\]" " = " + + # Test "info locals" + set r "" + set r "${r}locf = ${cr}" + set r "${r}locd = ${cr}" + set r "${r}locst = {memberc = , memberi = , memberf = , memberd = }${cr}" + set r "${r}locar = {, , , }${cr}" + set r "${r}i = ${cr}" + if { $func == "local_test_func" } { + set r "${r}locdefst = {}${cr}" + } + set r "${r}locc = ${cr}" + set r "${r}loci = ${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 -- 2.7.4