From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5991 invoked by alias); 13 Aug 2013 10:03:08 -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 5976 invoked by uid 89); 13 Aug 2013 10:03:07 -0000 X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,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; Tue, 13 Aug 2013 10:03:06 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1V9BRQ-0002rp-Vd from Muhammad_Waqas@mentor.com for gdb-patches@sourceware.org; Tue, 13 Aug 2013 03:03:05 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 13 Aug 2013 03:03:05 -0700 Received: from [137.202.157.111] (147.34.91.1) by SVR-ORW-FEM-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server (TLS) id 14.2.247.3; Tue, 13 Aug 2013 03:03:03 -0700 Message-ID: <520A0453.4070309@codesourcery.com> Date: Tue, 13 Aug 2013 10:03: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: Subject: [PATCH] fix PR-15501 Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00339.txt.bz2 Hi GDB enable/disable command does not work correctly as it should be. http://sourceware.org/bugzilla/show_bug.cgi?id=15501 Addition to Pedro examples. if we execute following commands these will be executed without an error. (gdb) info b Num Type Disp Enb Address What 1 breakpoint keep y 0x00000000004004b8 in main at 13929.c:13 2 breakpoint keep y 0x00000000004004b8 in main at 13929.c:13 (gdb) disable 1 fooo.1 (gdb) info break Num Type Disp Enb Address What 1 breakpoint keep y 1.1 n 0x00000000004004b8 in main at 13929.c:13 2 breakpoint keep y 0x00000000004004b8 in main at 13929.c:13 It should disable breakpoint 1 and error on fooo but what gdb did, it disable 1.1 surprisingly. I am prposing patch for this bug. Workaround: Pars args and handle them one by one if it contain period or not and do what it requires(disable/enable breakpoint or location). gdb\Changlog 2013-08-13 Muhammad Waqas PR gdb/15501 * breakpoint.c (enable_command): Handle multiple arguments properly. (disable_command): Handle multiple arguments properly. 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 13 Aug 2013 07:55:49 -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); } /* This struct packages up disposition data for application to multiple testsuite\Changlog 2013-07-13 Muhammad Waqas PR gdb/15501 * gdb.base/ena-dis-br.exp: Add test to verify enable\disable commands work correctly with arguments. 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 13 Aug 2013 07:57:26 -0000 @@ -301,5 +301,35 @@ gdb_test_multiple "continue 2" "$test" { } } +# Verify that GDB correctly handles the "enable/disable" command with arguments. +# +if ![runto_main] then { fail "enable/disable break tests suppressed" } + +set b1 0 +set b2 0 + +gdb_test_multiple "break main" "bp 1" { + -re "(Breakpoint )(\[0-9\]+)( at.* file .*$srcfile, line.*)($gdb_prompt $)" { + set b1 $expect_out(2,string) + pass "breakpoint main 1" + } +} + +gdb_test_multiple "break main" "bp 2" { + -re "(Breakpoint )(\[0-9\]+)( at.* file .*$srcfile, line.*)($gdb_prompt $)" { + set b2 $expect_out(2,string) + pass "breakpoint main 2" + } +} + +gdb_test_no_output "disable $b1.1 $b2.1" "disable command" +gdb_test "info break" \ + "(${b1}.1)(\[^\n\r\]*)( n.*)(${b2}.1)(\[^\n\r\]*)( n.*)" \ + "disable ${b1}.1 and ${b2}.1" + +gdb_test "disable $b1 fooo.1" \ + "Bad breakpoint number 'fooo'" \ + "handle multiple args" + gdb_exit return 0