From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79794 invoked by alias); 20 Jun 2016 14:33:44 -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 79781 invoked by uid 89); 20 Jun 2016 14:33:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=HX-Envelope-From:sk:mmetzge, sk:string_, 2516, 1831 X-HELO: mga04.intel.com Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Jun 2016 14:33:33 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP; 20 Jun 2016 07:33:09 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 20 Jun 2016 07:33:06 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u5KEX6um005423; Mon, 20 Jun 2016 15:33:06 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id u5KEX5RW029708; Mon, 20 Jun 2016 16:33:05 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id u5KEX58X029704; Mon, 20 Jun 2016 16:33:05 +0200 From: Markus Metzger To: gdb-patches@sourceware.org Cc: keiths@redhat.com Subject: [PATCH] python: accept address and explicit locations in gdb.decode_line Date: Mon, 20 Jun 2016 14:33:00 -0000 Message-Id: <1466433185-29434-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00328.txt.bz2 The gdb.decode_line python function is documented to support the same location expressions as the "break" command. It currently expects a linespec location. Instead of creating a linespec location directly, create the location via string_to_event_location_basic. It's not clear to me whether I should use python_language or current_language, though. Is there some comment that explains it? 2016-06-20 Markus Metzger gdb/ * python/python.c (gdbpy_decode_line): Call string_to_event_location_basic. testsuite/ * gdb.python/python.exp: Test decode_line("*0"). --- gdb/python/python.c | 2 +- gdb/testsuite/gdb.python/python.exp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gdb/python/python.c b/gdb/python/python.c index 1f1fece..7bee890 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -738,7 +738,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) if (arg != NULL) { - location = new_linespec_location (&arg); + location = string_to_event_location_basic (&arg, python_language); make_cleanup_delete_event_location (location); } diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 3f8c46f..4072fa3 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -251,6 +251,13 @@ gdb_py_test_silent_cmd {python symtab = gdb.decode_line ("func1,func2")} \ "test decode_line func1,func2" 1 gdb_test {python print (symtab[0])} ",func2" "stop at comma in linespec" +gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"*0\")" "Test decode_line *0" 1 +gdb_test "python print (len(symtab))" "2" "Test decode_line *0 result length" +gdb_test "python print (symtab\[0\])" "None" "Test decode_line *0 unparsed" +gdb_test "python print (len(symtab\[1\]))" "1" "Test decode_line *0 locations length" +gdb_test "python print (symtab\[1\]\[0\].symtab)" "None" "Test decode_line *0 filename" +gdb_test "python print (symtab\[1\]\[0\].pc)" "0" "Test decode_line *0 pc" + # gdb.write gdb_test "python print (sys.stderr)" ".*gdb.GdbOutputErrorFile (instance|object) at.*" "Test stderr location" gdb_test "python print (sys.stdout)" ".*gdb.GdbOutputFile (instance|object) at.*" "Test stdout location" -- 1.8.3.1