From 8abea1a1d29850eb914bd81e8f4199e29aeb9753 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Thu, 14 Nov 2013 22:36:19 -0800 Subject: [PATCH] * gdb.python/py-breakpoint.exp: Reformat for 80 columns. --- gdb/testsuite/ChangeLog | 4 + gdb/testsuite/gdb.python/py-breakpoint.exp | 239 +++++++++++++++++++---------- 2 files changed, 164 insertions(+), 79 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4c11729..bcc80ef 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2013-11-15 Doug Evans + * gdb.python/py-breakpoint.exp: Reformat for 80 columns. + +2013-11-15 Doug Evans + * gdb.python/py-breakpoint.exp: Split up into several functions, each with their own test prefix. diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index f48431a..64c4016 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -40,9 +40,12 @@ proc test_bkpt_basic { } { } # Initially there should be one breakpoint: main. - gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" "Get Breakpoint List" 0 - gdb_test "python print (blist\[0\])" "" "Check obj exists" - gdb_test "python print (blist\[0\].location)" "main." "Check breakpoint location" + gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \ + "Get Breakpoint List" 0 + gdb_test "python print (blist\[0\])" \ + "" "Check obj exists" + gdb_test "python print (blist\[0\].location)" \ + "main." "Check breakpoint location" set mult_line [gdb_get_line_number "Break at multiply."] gdb_breakpoint ${mult_line} @@ -50,38 +53,57 @@ proc test_bkpt_basic { } { # Check that the Python breakpoint code noted the addition of a # breakpoint "behind the scenes". - gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" "Get Breakpoint List" 0 - gdb_test "python print (len(blist))" "2" "Check for two breakpoints" - gdb_test "python print (blist\[0\])" "" "Check obj exists" - gdb_test "python print (blist\[0\].location)" "main." "Check breakpoint location" - gdb_test "python print (blist\[1\])" "" "Check obj exists" - - gdb_test "python print (blist\[1\].location)" "py-breakpoint\.c:${mult_line}*" \ + gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \ + "Get Breakpoint List" 0 + gdb_test "python print (len(blist))" \ + "2" "Check for two breakpoints" + gdb_test "python print (blist\[0\])" \ + "" "Check obj exists" + gdb_test "python print (blist\[0\].location)" \ + "main." "Check breakpoint location" + gdb_test "python print (blist\[1\])" \ + "" "Check obj exists" + + gdb_test "python print (blist\[1\].location)" \ + "py-breakpoint\.c:${mult_line}*" \ "Check breakpoint location" # Check hit and ignore counts. - gdb_test "python print (blist\[1\].hit_count)" "1" "Check breakpoint hit count" - gdb_py_test_silent_cmd "python blist\[1\].ignore_count = 4" "Set breakpoint hit count" 0 + gdb_test "python print (blist\[1\].hit_count)" \ + "1" "Check breakpoint hit count" + gdb_py_test_silent_cmd "python blist\[1\].ignore_count = 4" \ + "Set breakpoint hit count" 0 gdb_continue_to_breakpoint "Break at multiply." - gdb_test "python print (blist\[1\].hit_count)" "6" "Check breakpoint hit count" - gdb_test "print result" " = 545" "Check expected variable result after 6 iterations" + gdb_test "python print (blist\[1\].hit_count)" \ + "6" "Check breakpoint hit count" + gdb_test "print result" \ + " = 545" "Check expected variable result after 6 iterations" # Test breakpoint is enabled and disabled correctly.. gdb_breakpoint [gdb_get_line_number "Break at add."] gdb_continue_to_breakpoint "Break at add." - gdb_test "python print (blist\[1\].enabled)" "True" "Check breakpoint enabled." - gdb_py_test_silent_cmd "python blist\[1\].enabled = False" "Set breakpoint disabled." 0 + gdb_test "python print (blist\[1\].enabled)" \ + "True" "Check breakpoint enabled." + gdb_py_test_silent_cmd "python blist\[1\].enabled = False" \ + "Set breakpoint disabled." 0 gdb_continue_to_breakpoint "Break at add." - gdb_py_test_silent_cmd "python blist\[1\].enabled = True" "Set breakpoint enabled." 0 + gdb_py_test_silent_cmd "python blist\[1\].enabled = True" \ + "Set breakpoint enabled." 0 gdb_continue_to_breakpoint "Break at multiply." # Test other getters and setters. - gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" "Get Breakpoint List" 0 - gdb_test "python print (blist\[1\].thread)" "None" "Check breakpoint thread" - gdb_test "python print (blist\[1\].type == gdb.BP_BREAKPOINT)" "True" "Check breakpoint type" - gdb_test "python print (blist\[0\].number)" "1" "Check breakpoint number" - gdb_test "python print (blist\[1\].number)" "2" "Check breakpoint number" - gdb_test "python print (blist\[2\].number)" "3" "Check breakpoint number" + gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \ + "Get Breakpoint List" 0 + gdb_test "python print (blist\[1\].thread)" \ + "None" "Check breakpoint thread" + gdb_test "python print (blist\[1\].type == gdb.BP_BREAKPOINT)" \ + "True" "Check breakpoint type" + gdb_test "python print (blist\[0\].number)" \ + "1" "Check breakpoint number" + gdb_test "python print (blist\[1\].number)" \ + "2" "Check breakpoint number" + gdb_test "python print (blist\[2\].number)" \ + "3" "Check breakpoint number" } } @@ -100,16 +122,26 @@ proc test_bkpt_deletion { } { # Test breakpoints are deleted correctly. set deltst_location [gdb_get_line_number "Break at multiply."] set end_location [gdb_get_line_number "Break at end."] - gdb_py_test_silent_cmd "python dp1 = gdb.Breakpoint (\"$deltst_location\")" "Set breakpoint" 0 + gdb_py_test_silent_cmd "python dp1 = gdb.Breakpoint (\"$deltst_location\")" \ + "Set breakpoint" 0 gdb_breakpoint [gdb_get_line_number "Break at end."] - gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" "Get Breakpoint List" 0 - gdb_test "python print (len(del_list))" "3" "Number of breakpoints before delete" - gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$deltst_location.*" - gdb_py_test_silent_cmd "python dp1.delete()" "Delete Breakpoint" 0 - gdb_test "python print (dp1.number)" "RuntimeError: Breakpoint 2 is invalid.*" "Check breakpoint invalidated" - gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" "Get Breakpoint List" 0 - gdb_test "python print (len(del_list))" "2" "Number of breakpoints after delete" - gdb_continue_to_breakpoint "Break at end." ".*/$srcfile:$end_location.*" + gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" \ + "Get Breakpoint List" 0 + gdb_test "python print (len(del_list))" \ + "3" "Number of breakpoints before delete" + gdb_continue_to_breakpoint "Break at multiply." \ + ".*/$srcfile:$deltst_location.*" + gdb_py_test_silent_cmd "python dp1.delete()" \ + "Delete Breakpoint" 0 + gdb_test "python print (dp1.number)" \ + "RuntimeError: Breakpoint 2 is invalid.*" \ + "Check breakpoint invalidated" + gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" \ + "Get Breakpoint List" 0 + gdb_test "python print (len(del_list))" \ + "2" "Number of breakpoints after delete" + gdb_continue_to_breakpoint "Break at end." \ + ".*/$srcfile:$end_location.*" } } @@ -127,16 +159,23 @@ proc test_bkpt_cond_and_cmds { } { # Test conditional setting. set bp_location1 [gdb_get_line_number "Break at multiply."] - gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (\"$bp_location1\")" "Set breakpoint" 0 + gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (\"$bp_location1\")" \ + "Set breakpoint" 0 gdb_continue_to_breakpoint "Break at multiply." - gdb_py_test_silent_cmd "python bp1.condition = \"i == 5\"" "Set breakpoint" 0 - gdb_test "python print (bp1.condition)" "i == 5" "Test conditional has been set" + gdb_py_test_silent_cmd "python bp1.condition = \"i == 5\"" \ + "Set breakpoint" 0 + gdb_test "python print (bp1.condition)" "i == 5" \ + "Test conditional has been set" gdb_continue_to_breakpoint "Break at multiply." - gdb_test "print i" "5" "Test conditional breakpoint stopped after five iterations" - gdb_py_test_silent_cmd "python bp1.condition = None" "Clear condition" 0 - gdb_test "python print (bp1.condition)" "None" "Test conditional read" + gdb_test "print i" \ + "5" "Test conditional breakpoint stopped after five iterations" + gdb_py_test_silent_cmd "python bp1.condition = None" \ + "Clear condition" 0 + gdb_test "python print (bp1.condition)" \ + "None" "Test conditional read" gdb_continue_to_breakpoint "Break at multiply." - gdb_test "print i" "6" "Test breakpoint stopped after six iterations" + gdb_test "print i" \ + "6" "Test breakpoint stopped after six iterations" # Test commands. gdb_breakpoint [gdb_get_line_number "Break at add."] @@ -148,8 +187,10 @@ proc test_bkpt_cond_and_cmds { } { gdb_test_multiple $test $test { -re "\r\n>$" { pass $test } } gdb_test "end" - gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" "Get Breakpoint List" 0 - gdb_test "python print (blist\[len(blist)-1\].commands)" "print \"Command for breakpoint has been executed.\".*print result" + gdb_py_test_silent_cmd "python blist = gdb.breakpoints()" \ + "Get Breakpoint List" 0 + gdb_test "python print (blist\[len(blist)-1\].commands)" \ + "print \"Command for breakpoint has been executed.\".*print result" } } @@ -167,20 +208,34 @@ proc test_bkpt_invisible { } { delete_breakpoints set ibp_location [gdb_get_line_number "Break at multiply."] - gdb_py_test_silent_cmd "python ibp = gdb.Breakpoint(\"$ibp_location\", internal=False)" "Set invisible breakpoint" 0 - gdb_py_test_silent_cmd "python ilist = gdb.breakpoints()" "Get Breakpoint List" 0 - gdb_test "python print (ilist\[0\])" "" "Check invisible bp obj exists" - gdb_test "python print (ilist\[0\].location)" "py-breakpoint\.c:$ibp_location*" "Check breakpoint location" - gdb_test "python print (ilist\[0\].visible)" "True" "Check breakpoint visibility" - gdb_test "info breakpoints" "py-breakpoint\.c:$ibp_location.*" "Check info breakpoints shows visible breakpoints" + gdb_py_test_silent_cmd "python ibp = gdb.Breakpoint(\"$ibp_location\", internal=False)" \ + "Set invisible breakpoint" 0 + gdb_py_test_silent_cmd "python ilist = gdb.breakpoints()" \ + "Get Breakpoint List" 0 + gdb_test "python print (ilist\[0\])" \ + "" "Check invisible bp obj exists" + gdb_test "python print (ilist\[0\].location)" \ + "py-breakpoint\.c:$ibp_location*" "Check breakpoint location" + gdb_test "python print (ilist\[0\].visible)" \ + "True" "Check breakpoint visibility" + gdb_test "info breakpoints" "py-breakpoint\.c:$ibp_location.*" \ + "Check info breakpoints shows visible breakpoints" delete_breakpoints - gdb_py_test_silent_cmd "python ibp = gdb.Breakpoint(\"$ibp_location\", internal=True)" "Set invisible breakpoint" 0 - gdb_py_test_silent_cmd "python ilist = gdb.breakpoints()" "Get Breakpoint List" 0 - gdb_test "python print (ilist\[0\])" "" "Check invisible bp obj exists" - gdb_test "python print (ilist\[0\].location)" "py-breakpoint\.c:$ibp_location*" "Check breakpoint location" - gdb_test "python print (ilist\[0\].visible)" "False" "Check breakpoint visibility" - gdb_test "info breakpoints" "No breakpoints or watchpoints.*" "Check info breakpoints does not show invisible breakpoints" - gdb_test "maint info breakpoints" "py-breakpoint\.c:$ibp_location.*" "Check maint info breakpoints shows invisible breakpoints" + gdb_py_test_silent_cmd "python ibp = gdb.Breakpoint(\"$ibp_location\", internal=True)" \ + "Set invisible breakpoint" 0 + gdb_py_test_silent_cmd "python ilist = gdb.breakpoints()" \ + "Get Breakpoint List" 0 + gdb_test "python print (ilist\[0\])" \ + "" "Check invisible bp obj exists" + gdb_test "python print (ilist\[0\].location)" \ + "py-breakpoint\.c:$ibp_location*" "Check breakpoint location" + gdb_test "python print (ilist\[0\].visible)" \ + "False" "Check breakpoint visibility" + gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \ + "Check info breakpoints does not show invisible breakpoints" + gdb_test "maint info breakpoints" \ + "py-breakpoint\.c:$ibp_location.*" \ + "Check maint info breakpoints shows invisible breakpoints" } } @@ -201,8 +256,11 @@ proc test_watchpoints { } { return 0 } - gdb_py_test_silent_cmd "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE )" "Set watchpoint" 0 - gdb_test "continue" ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*main.*" "Test watchpoint write" + gdb_py_test_silent_cmd "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE )" \ + "Set watchpoint" 0 + gdb_test "continue" \ + ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*main.*" \ + "Test watchpoint write" } } @@ -222,10 +280,17 @@ proc test_bkpt_internal { } { return 0 } delete_breakpoints - gdb_py_test_silent_cmd "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE, internal=True )" "Set watchpoint" 0 - gdb_test "info breakpoints" "No breakpoints or watchpoints.*" "Check info breakpoints does not show invisible breakpoints" - gdb_test "maint info breakpoints" ".*watchpoint.*result.*" "Check maint info breakpoints shows invisible breakpoints" - gdb_test "continue" ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*" "Test watchpoint write" + gdb_py_test_silent_cmd "python wp1 = gdb.Breakpoint (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE, internal=True )" \ + "Set watchpoint" 0 + gdb_test "info breakpoints" \ + "No breakpoints or watchpoints.*" \ + "Check info breakpoints does not show invisible breakpoints" + gdb_test "maint info breakpoints" \ + ".*watchpoint.*result.*" \ + "Check maint info breakpoints shows invisible breakpoints" + gdb_test "continue" \ + ".*\[Ww\]atchpoint.*result.*Old value = 0.*New value = 25.*" \ + "Test watchpoint write" } } @@ -278,12 +343,18 @@ proc test_bkpt_eval_funcs { } { set bp_location2 [gdb_get_line_number "Break at multiply."] set end_location [gdb_get_line_number "Break at end."] - gdb_py_test_silent_cmd "python eval_bp1 = bp_eval(\"$bp_location2\")" "Set breakpoint" 0 - gdb_py_test_silent_cmd "python also_eval_bp1 = bp_also_eval(\"$bp_location2\")" "Set breakpoint" 0 - gdb_py_test_silent_cmd "python never_eval_bp1 = bp_also_eval(\"$end_location\")" "Set breakpoint" 0 - gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$bp_location2.*" - gdb_test "print i" "3" "Check inferior value matches python accounting" - gdb_test "python print (eval_bp1.inf_i)" "3" "Check python accounting matches inferior" + gdb_py_test_silent_cmd "python eval_bp1 = bp_eval(\"$bp_location2\")" \ + "Set breakpoint" 0 + gdb_py_test_silent_cmd "python also_eval_bp1 = bp_also_eval(\"$bp_location2\")" \ + "Set breakpoint" 0 + gdb_py_test_silent_cmd "python never_eval_bp1 = bp_also_eval(\"$end_location\")" \ + "Set breakpoint" 0 + gdb_continue_to_breakpoint "Break at multiply." \ + ".*/$srcfile:$bp_location2.*" + gdb_test "print i" \ + "3" "Check inferior value matches python accounting" + gdb_test "python print (eval_bp1.inf_i)" \ + "3" "Check python accounting matches inferior" gdb_test "python print (also_eval_bp1.count)" "4" \ "Check non firing same-location breakpoint eval function was also called at each stop." gdb_test "python print (eval_bp1.count)" "4" \ @@ -291,13 +362,16 @@ proc test_bkpt_eval_funcs { } { delete_breakpoints set cond_bp [gdb_get_line_number "Break at multiply."] - gdb_py_test_silent_cmd "python eval_bp1 = bp_eval(\"$cond_bp\")" "Set breakpoint" 0 + gdb_py_test_silent_cmd "python eval_bp1 = bp_eval(\"$cond_bp\")" \ + "Set breakpoint" 0 set test_cond {cond $bpnum} - gdb_test "$test_cond \"foo==3\"" "Cannot set a condition where a Python.*" \ - "Check you cannot add a CLI condition to a Python breakpoint that" \ - "has defined stop" - gdb_py_test_silent_cmd "python eval_bp2 = basic(\"$cond_bp\")" "Set breakpoint" 0 - gdb_py_test_silent_cmd "python eval_bp2.condition = \"1==1\"" "Set a condition" 0 + gdb_test "$test_cond \"foo==3\"" \ + "Cannot set a condition where a Python.*" \ + "Check you cannot add a CLI condition to a Python breakpoint that has defined stop" + gdb_py_test_silent_cmd "python eval_bp2 = basic(\"$cond_bp\")" \ + "Set breakpoint" 0 + gdb_py_test_silent_cmd "python eval_bp2.condition = \"1==1\"" \ + "Set a condition" 0 gdb_py_test_multiple "Construct an eval function" \ "python" "" \ "def stop_func ():" "" \ @@ -310,10 +384,12 @@ proc test_bkpt_eval_funcs { } { delete_breakpoints gdb_breakpoint [gdb_get_line_number "Break at multiply."] - gdb_py_test_silent_cmd "python check_eval = bp_eval(\"$bp_location2\")" "Set breakpoint" 0 + gdb_py_test_silent_cmd "python check_eval = bp_eval(\"$bp_location2\")" \ + "Set breakpoint" 0 gdb_test "python print (check_eval.count)" "0" \ "Test that evaluate function has not been yet executed (ie count = 0)" - gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$bp_location2.*" + gdb_continue_to_breakpoint "Break at multiply." \ + ".*/$srcfile:$bp_location2.*" gdb_test "python print (check_eval.count)" "1" \ "Test that evaluate function is run when location also has normal bp" @@ -328,8 +404,11 @@ proc test_bkpt_eval_funcs { } { "end" "" delete_breakpoints - gdb_py_test_silent_cmd "python wp1 = wp_eval (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE)" "Set watchpoint" 0 - gdb_test "continue" ".*\[Ww\]atchpoint.*result.*Old value =.*New value = 788.*" "Test watchpoint write" + gdb_py_test_silent_cmd "python wp1 = wp_eval (\"result\", type=gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE)" \ + "Set watchpoint" 0 + gdb_test "continue" \ + ".*\[Ww\]atchpoint.*result.*Old value =.*New value = 788.*" \ + "Test watchpoint write" gdb_test "python print (never_eval_bp1.count)" "0" \ "Check that this unrelated breakpoints eval function was never called." } @@ -357,15 +436,17 @@ proc test_bkpt_temporary { } { " return True" "" \ "end" "" set ibp_location [gdb_get_line_number "Break at multiply."] - gdb_py_test_silent_cmd "python ibp = temp_bp(\"$ibp_location\", temporary=True)" \ + gdb_py_test_silent_cmd "python ibp = temp_bp(\"$ibp_location\", temporary=True)" \ "Set temporary breakpoint" 0 - gdb_test "info breakpoints" "2.*breakpoint.*del.*py-breakpoint\.c:$ibp_location.*" \ + gdb_test "info breakpoints" \ + "2.*breakpoint.*del.*py-breakpoint\.c:$ibp_location.*" \ "Check info breakpoints shows breakpoint with temporary status" gdb_test "python print (ibp.location)" "py-breakpoint\.c:$ibp_location*" \ "Check temporary breakpoint location" gdb_test "python print (ibp.temporary)" "True" \ "Check breakpoint temporary status" - gdb_continue_to_breakpoint "Break at multiply." ".*/$srcfile:$ibp_location.*" + gdb_continue_to_breakpoint "Break at multiply." \ + ".*/$srcfile:$ibp_location.*" gdb_test "python print (ibp.count)" "1" \ "Check temporary stop callback executed before deletion." gdb_test "python print (ibp.temporary)" "RuntimeError: Breakpoint 2 is invalid.*" \ -- 2.7.4