From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9838 invoked by alias); 23 Aug 2013 07:27:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9829 invoked by uid 89); 23 Aug 2013 07:27:22 -0000 X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.2 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 23 Aug 2013 07:26:51 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1VCllh-0001Te-PS from Muhammad_Waqas@mentor.com ; Fri, 23 Aug 2013 00:26:49 -0700 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 23 Aug 2013 00:26:49 -0700 Received: from [137.202.157.111] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server (TLS) id 14.2.247.3; Fri, 23 Aug 2013 08:26:47 +0100 Message-ID: <52170EA8.7090501@codesourcery.com> Date: Fri, 23 Aug 2013 07:27:00 -0000 From: Muhammad Waqas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-Version: 1.0 To: Pedro Alves CC: "Waqas, Muhammad" , "gdb-patches@sourceware.org" Subject: Re: [PATCH] fix PR-15501 References: <520A0453.4070309@codesourcery.com> <520A6EEB.8010808@redhat.com> <520CAE24.7050301@codesourcery.com>,<52153C74.7080708@redhat.com> <53A5AC689E2AD547AE0EA5642E101306BB6120@EU-MBX-04.mgc.mentorg.com>,<5215FDBE.1060209@redhat.com> <53A5AC689E2AD547AE0EA5642E101306BB63F5@EU-MBX-04.mgc.mentorg.com> <52161505.5000909@redhat.com> In-Reply-To: <52161505.5000909@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00666.txt.bz2 Thanks. Below is the committed patch. gdb/ChangeLog 2013-08-12 Muhammad Waqas PR gdb/15501 * breakpoint.c (enable_command, disable_command): Iterate over all specified breakpoint locations. Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.773 diff -u -p -r1.773 breakpoint.c --- breakpoint.c 24 Jul 2013 19:50:32 -0000 1.773 +++ breakpoint.c 22 Aug 2013 06:37:27 -0000 @@ -14553,25 +14553,35 @@ disable_command (char *args, int from_tt if (user_breakpoint_p (bpt)) disable_breakpoint (bpt); } - else if (strchr (args, '.')) + else { - struct bp_location *loc = find_location_by_number (args); - if (loc) + char *num = extract_arg (&args); + + while (num) { - if (loc->enabled) + if (strchr (num, '.')) { - loc->enabled = 0; - mark_breakpoint_location_modified (loc); + struct bp_location *loc = find_location_by_number (num); + + if (loc) + { + if (loc->enabled) + { + loc->enabled = 0; + mark_breakpoint_location_modified (loc); + } + if (target_supports_enable_disable_tracepoint () + && current_trace_status ()->running && loc->owner + && is_tracepoint (loc->owner)) + target_disable_tracepoint (loc); + } + update_global_location_list (0); } - if (target_supports_enable_disable_tracepoint () - && current_trace_status ()->running && loc->owner - && is_tracepoint (loc->owner)) - target_disable_tracepoint (loc); + else + map_breakpoint_numbers (num, do_map_disable_breakpoint, NULL); + num = extract_arg (&args); } - update_global_location_list (0); } - else - map_breakpoint_numbers (args, do_map_disable_breakpoint, NULL); } static void @@ -14677,25 +14687,35 @@ enable_command (char *args, int from_tty if (user_breakpoint_p (bpt)) enable_breakpoint (bpt); } - else if (strchr (args, '.')) + else { - struct bp_location *loc = find_location_by_number (args); - if (loc) + char *num = extract_arg (&args); + + while (num) { - if (!loc->enabled) + if (strchr (num, '.')) { - loc->enabled = 1; - mark_breakpoint_location_modified (loc); + struct bp_location *loc = find_location_by_number (num); + + if (loc) + { + if (!loc->enabled) + { + loc->enabled = 1; + mark_breakpoint_location_modified (loc); + } + if (target_supports_enable_disable_tracepoint () + && current_trace_status ()->running && loc->owner + && is_tracepoint (loc->owner)) + target_enable_tracepoint (loc); + } + update_global_location_list (1); } - if (target_supports_enable_disable_tracepoint () - && current_trace_status ()->running && loc->owner - && is_tracepoint (loc->owner)) - target_enable_tracepoint (loc); + else + map_breakpoint_numbers (num, do_map_enable_breakpoint, NULL); + num = extract_arg (&args); } - update_global_location_list (1); } - else - map_breakpoint_numbers (args, do_map_enable_breakpoint, NULL); } gdb/testsuite/ChangeLog 2013-07-12 Muhammad Waqas PR gdb/15501 * gdb.base/ena-dis-br.exp: Add test to verify enable/disable commands work correctly with multiple arguments that include multiple locations. Index: ena-dis-br.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/ena-dis-br.exp,v retrieving revision 1.22 diff -u -p -r1.22 ena-dis-br.exp --- ena-dis-br.exp 27 Jun 2013 18:50:30 -0000 1.22 +++ ena-dis-br.exp 23 Aug 2013 05:37:54 -0000 @@ -301,5 +301,113 @@ gdb_test_multiple "continue 2" "$test" { } } +# Verify that GDB correctly handles the "enable/disable" command +# with arguments, that include multiple locations. +# +if ![runto_main] then { fail "enable/disable break tests suppressed" } + +set b1 0 +set b2 0 +set b3 0 +set b4 0 +set b1 [break_at main ""] +set b2 [break_at main ""] +set b3 [break_at main ""] +set b4 [break_at main ""] + +# Perform tests for disable/enable commands on multiple +# locations and breakpoints. +# +# WHAT - the command to test (disable/enable). +# +proc test_ena_dis_br { what } { + global b1 + global b2 + global b3 + global b4 + global gdb_prompt + + # OPPOS - the command opposite to WHAT. + # WHAT_RES - whether breakpoints are expected to end + # up enabled or disabled. + # OPPOS_RES- same as WHAT_RES but opposite. + # P1/P2 - proc to call (pass/fail). Must be + # opposites. + # Set variable values for disable command. + set oppos "enable" + set oppos_res "y" + set what_res "n" + set p1 "pass" + set p2 "fail" + + if { "$what" == "enable" } { + # Set variable values for enable command. + set oppos "disable" + set oppos_res "n" + set what_res "y" + set p1 "fail" + set p2 "pass" + } + + # Now enable(disable) $b.1 $b2.1. + gdb_test_no_output "$what $b1.1 $b2.1" "$what \$b1.1 \$b2.1" + set test1 "${what}d \$b1.1 and \$b2.1" + + # Now $b1.1 and $b2.1 should be enabled(disabled). + gdb_test_multiple "info break" "$test1" { + -re "(${b1}.1)(\[^\n\r\]*)( n.*)(${b2}.1)(\[^\n\r\]*)( n.*)$gdb_prompt $" { + $p1 "$test1" + } + -re ".*$gdb_prompt $" { + $p2 "$test1" + } + } + + # Now enable(disable) $b1 fooo.1, it should give error on fooo. + gdb_test "$what $b1 fooo.1" \ + "Bad breakpoint number 'fooo'" \ + "$what \$b1 fooo.1" + + # $b1 should be enabled(disabled). + gdb_test "info break" \ + "(${b1})(\[^\n\r]*)( $what_res.*)" \ + "${what}d \$b1" + + gdb_test_no_output "$oppos $b3" "$oppos \$b3" + gdb_test_no_output "$what $b4 $b3.1" "$what \$b4 \$b3.1" + set test1 "${what}d \$b4 and \$b3.1,remain ${oppos}d \$b3" + + # Now $b4 $b3.1 should be enabled(disabled) and + # $b3 should remain disabled(enabled). + gdb_test_multiple "info break" "$test1" { + -re "(${b3})(\[^\n\r]*)( $oppos_res.*)(${b3}.1)(\[^\n\r\]*)( n.*)(${b4})(\[^\n\r\]*)( $what_res.*)$gdb_prompt $" { + $p1 "$test1" + } + -re "(${b3})(\[^\n\r]*)( $oppos_res.*)(${b4})(\[^\n\r\]*)( $what_res.*)$gdb_prompt $" { + $p2 "$test1" + } + } + + # Now enable(disable) $b4.1 fooobaar and + # it should give warning on fooobaar. + gdb_test "$what $b4.1 fooobaar" \ + "warning: bad breakpoint number at or near 'fooobaar'" \ + "$what \$b4.1 fooobar" + set test1 "${what}d \$b4.1" + + # $b4.1 should be enabled(disabled). + gdb_test_multiple "info break" "$test1" { + -re "(${b4}.1)(\[^\n\r\]*)( n.*)$gdb_prompt $" { + $p1 "$test1" + } + -re ".*$gdb_prompt $" { + $p2 "$test1" + } + } +} + +test_ena_dis_br "disable" +test_ena_dis_br "enable" + gdb_exit return 0