From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32417 invoked by alias); 22 Oct 2013 17:59:45 -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 32365 invoked by uid 89); 22 Oct 2013 17:59:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Oct 2013 17:59:39 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9MHxcHw023242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 22 Oct 2013 13:59:38 -0400 Received: from barimba.redhat.com (ovpn-113-54.phx2.redhat.com [10.3.113.54]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9MHxZvi011450; Tue, 22 Oct 2013 13:59:38 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Pedro Alves Subject: [PATCH v4 4/9] PR gdb/13860: make -interpreter-exec console "list" behave more like "list". Date: Tue, 22 Oct 2013 17:59:00 -0000 Message-Id: <1382464769-2465-5-git-send-email-tromey@redhat.com> In-Reply-To: <1382464769-2465-1-git-send-email-tromey@redhat.com> References: <1382464769-2465-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-10/txt/msg00696.txt.bz2 From: Pedro Alves Patch 3 in this series made me notice that "list" behaves differently in CLI vs MI. Particularly: >./gdb -nx -q ./testsuite/gdb.mi/mi-cli Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli...done. (gdb) start Temporary breakpoint 1 at 0x40054d: file ../../../src/gdb/testsuite/gdb.mi/basics.c, line 62. Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli Temporary breakpoint 1, main () at ../../../src/gdb/testsuite/gdb.mi/basics.c:62 62 callee1 (2, "A string argument.", 3.5); (gdb) list 57 { 58 } 59 60 main () 61 { 62 callee1 (2, "A string argument.", 3.5); 63 callee1 (2, "A string argument.", 3.5); 64 65 do_nothing (); /* Hello, World! */ 66 (gdb) Note the list started at line 57. IOW, the program stopped at line 62, and GDB centered the list on that. compare with: >./gdb -nx -q ./testsuite/gdb.mi/mi-cli -i=mi =thread-group-added,id="i1" ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli..." ~"done.\n" (gdb) start &"start\n" ~"Temporary breakpoint 1 at 0x40054d: file ../../../src/gdb/testsuite/gdb.mi/basics.c, line 62.\n" =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x000000000040054d",func="main",file="../../../src/gdb/testsuite/gdb.mi/basics.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/basics.c",line="62",times="0",original-location="main"} ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli \n" =thread-group-started,id="i1",pid="14221" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1" =library-loaded,id="/lib64/libm.so.6",target-name="/lib64/libm.so.6",host-name="/lib64/libm.so.6",symbols-loaded="0",thread-group="i1" =library-loaded,id="/lib64/libc.so.6",target-name="/lib64/libc.so.6",host-name="/lib64/libc.so.6",symbols-loaded="0",thread-group="i1" =breakpoint-modified,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x000000000040054d",func="main",file="../../../src/gdb/testsuite/gdb.mi/basics.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/basics.c",line="62",times="1",original-location="main"} ~"\nTemporary breakpoint " ~"1, main () at ../../../src/gdb/testsuite/gdb.mi/basics.c:62\n" ~"62\t callee1 (2, \"A string argument.\", 3.5);\n" *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x000000000040054d",func="main",args=[],file="../../../src/gdb/testsuite/gdb.mi/basics.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/basics.c",line="62"},thread-id="1",stopped-threads="all",core="0" =breakpoint-deleted,id="1" (gdb) -interpreter-exec console list ~"62\t callee1 (2, \"A string argument.\", 3.5);\n" ~"63\t callee1 (2, \"A string argument.\", 3.5);\n" ~"64\t\n" ~"65\t do_nothing (); /* Hello, World! */\n" ~"66\t\n" ~"67\t callme (1);\n" ~"68\t callme (2);\n" ~"69\t\n" ~"70\t return 0;\n" ~"71\t}\n" ^done (gdb) Here the list starts at line 62, where the program was stopped. This happens because print_stack_frame, called from both normal_stop and mi_on_normal_stop, is the function responsible for setting the current sal from the selected frame, overrides the PRINT_WHAT argument, and only after that does it decide whether to center the current sal line or not, based on the overriden value, and it will always decide false. (The print_stack_frame call in mi_on_normal_stop is a little different from the call in normal_stop, in that it is an unconditional SRC_AND_LOC call. The next patch will make those uniform.) Tested on x86_64 Fedora 16, no regressions. gdb/ 2012-05-09 Pedro Alves * stack.c (print_stack_frame): Compute CENTER before overriding PRINT_WHAT. gdb/testsuite/ 2012-05-09 Pedro Alves * gdb.mi/mi-cli.exp: Adjust expected output of "list". --- gdb/stack.c | 4 ++-- gdb/testsuite/gdb.mi/mi-cli.exp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gdb/stack.c b/gdb/stack.c index cd4ac7a..c325cc2 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -159,14 +159,14 @@ print_stack_frame (struct frame_info *frame, int print_level, { volatile struct gdb_exception e; + int center = (print_what == SRC_LINE || print_what == SRC_AND_LOC); + /* For mi, alway print location and address. */ if (ui_out_is_mi_like_p (current_uiout)) print_what = LOC_AND_ADDRESS; TRY_CATCH (e, RETURN_MASK_ERROR) { - int center = (print_what == SRC_LINE || print_what == SRC_AND_LOC); - print_frame_info (frame, print_level, print_what, 1 /* print_args */, set_current_sal); if (set_current_sal) diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp index 59af58b..5b809e2 100644 --- a/gdb/testsuite/gdb.mi/mi-cli.exp +++ b/gdb/testsuite/gdb.mi/mi-cli.exp @@ -91,7 +91,7 @@ mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \ # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } mi_gdb_test "-interpreter-exec console \"list\"" \ - ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ + ".*\~\"57\\\\t\{\\\\n\".*\\^done" \ "-interpreter-exec console \"list\"" mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \ -- 1.8.1.4