From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42954 invoked by alias); 9 Mar 2017 19:12:28 -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 40435 invoked by uid 89); 9 Mar 2017 19:12:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=899, 7910, UD:mi-cmds.c, mi-cmds.c X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 09 Mar 2017 19:12:20 +0000 Received: from ESESSHC006.ericsson.se (Unknown_Domain [153.88.183.36]) by (Symantec Mail Security) with SMTP id 75.B1.10506.119A1C85; Thu, 9 Mar 2017 20:12:17 +0100 (CET) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.36) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 9 Mar 2017 20:12:16 +0100 Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=ericsson.com; Received: from [142.133.51.175] (192.75.88.130) by AM4PR07MB1266.eurprd07.prod.outlook.com (10.164.81.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.8; Thu, 9 Mar 2017 19:12:14 +0000 Subject: Re: [Patch v5] Add -file-list-shared-libraries MI command To: References: <838tooorew.fsf@gnu.org> <20170302145500.10230-1-marc-andre.laperle@ericsson.com> From: =?UTF-8?Q?Marc-Andr=c3=a9_Laperle?= Message-ID: <829ed13f-a34b-c2dd-558b-d699091f0346@ericsson.com> Date: Thu, 09 Mar 2017 19:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170302145500.10230-1-marc-andre.laperle@ericsson.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: CY4PR20CA0021.namprd20.prod.outlook.com (10.173.116.159) To AM4PR07MB1266.eurprd07.prod.outlook.com (10.164.81.148) X-MS-Office365-Filtering-Correlation-Id: 61181e65-6aec-49a3-7ccf-08d467203298 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:AM4PR07MB1266; X-Microsoft-Exchange-Diagnostics: 1;AM4PR07MB1266;3:85nic+CO/IXR1rPJ1/A9qTQd/BQKrhHjnP55BMEzdMNlyjYEDdr1xztUf3CTDq7sWG0oAStkiHUeY2NX8boTZrIBFDDYk9rC7ji/CN78rB7fvRQjf+SgvNIgEypR4N7GQo0thFpsgc9E3FXB9LoONkH5nSFXCVcyN8vcke8SqI6Nts2gTWcxDlq69yteiX4o/YQlQ56N2aiRoh4UcY8Z56re3w2E2peZIynsj3ap1jKldGxKv4dbgeUHPR5f/ex4l70Y0ISYr3ik/i7ckF3O6A==;25:YZ4efv1fYm6sArbm0VBreU3BzOtCaHpLht3pNbJzA6hymK1E/qJuCow2AV7UEKp0vsCA/kJ7IPaFum5iDsNFHF6ozDY2EEdnTM1OvdQPO6UeggqTwURJeJ3EzwC1WUtyCZYi4Vv/hUFChm1KPwQ0cdva2YXcvX442sidD3zBY+hIbDZWF+0CfZ0hsDobvIfYs82LXfi2Rq38gt7f0Zu5j+qpmYkOCIOoQb2gIIEayzTa9+AKHBWTEuGL5xDjaqPQrG2uEX+owXTm0/6Fdi0qGiXlo1bQAOClPHmtHjRG8lsi2NRFNFS21Xmqcjb/OvlZftVIU4vTQXI7eZgGpER3KBJ2YMkb3gpchwvT7AQSeA7yyrB2J2py8+mUgNcV8o5ggYZNNJsLM3yRQ8Rfvei+Oydkp6EQG9mujZ5oi0BUkYYPV0R9XepS6DEvlpdfE3BbYuKmlj+xe2aOdlNgtuqG3Q== X-Microsoft-Exchange-Diagnostics: 1;AM4PR07MB1266;31:7uJYDeYPx/ImfnXBliT1GMB+rqaJ/PlBgITyIoqpP4WE8Rv/A61AlznaQTdwZqYlcXcUaMz/+Ztw1J9LIJmA3yb7gyAKEMAntmOxVTL34+K5IrdilwLQww/GnZLKhG+da2IHKf30P9BsySr0D3U+VVzDhctx4JaMX6+l78Ism5lwAmUkq5bEhokXv7qN/qX4VXvZZSqptE8Q6R99Ts1gNa1739tmr8VJEt5gt//41FdoLf4fgtCWGnQZnS4kwnFd83JB/AMlNV+gWnSilpLhIA==;20:5aSHbXkY7XLb89UZnPyrTvNdbOKMGXLgmiotMkRNeQFPIPPEWKXNcTGVhPWthVAuGB64kWGA0Zt6It48BvsilIedDko8M9LusUkvGOhx2RLrn1mh5ujbaM5NnkZ3yKOJc9DKLu33fDvAvLvG8XklSpOS0pnie78mudRGlSC376CqzdSWCztvqjmIPlnsRRH9VXV+yy5N/0Fi+5JVHQGDbjqtLjLecRwFYfdtTNxPeZ6jYSvXHIutAI8SV01QN32jEYYkcyTruPdx/SsDH/NTXOL+cyvfgF0jbryz1AuADPHwb/jag/pZyW2Zl/YIX1usUnmIf9u+CgLn2qtDKm7I2uIPqwllZmz/JnHZStipdr/ZAU+13bRtagywumopy7jo4+tstmmkLlxt+MbK0/4PfdR8woudzY0cR/CxD3lQwqacLme2zKYC5pRXP4vA0E2L6S2ODolIwUCuHbhW4JjmWCKdIT2A3Yi+cov6Rb9gH+CQF+z8NY110EZmLDuvHONg X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(37575265505322)(250305191791016)(20558992708506)(22074186197030)(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123560025)(20161123564025)(20161123558025)(6072148);SRVR:AM4PR07MB1266;BCL:0;PCL:0;RULEID:;SRVR:AM4PR07MB1266; X-Microsoft-Exchange-Diagnostics: 1;AM4PR07MB1266;4:4EsXlteOG5jdb84+YKCAVfWdOgeWW8aLneChQJnvLPJhc3rXKAUktGV6dQ5XBsaplc0jATKXEBnt5Izhj8F2LlYtA4M2e2ANGX00/IwvmlpHE7KlohLnxmO2HiUwcsAJDw1Dep0AqIdwvtx4PkiWrztIfoUb/YDgZAST0vzq/7Cda/t/LYQvssKUdZ/6tk2B9sGC9nkEvKI2KxCK8px1tEwQMfpU8y4HyjZ9cXj6LmQ9Ph3WgLZu9w+tbpI7h0g24KaiNP0dEq/pV2jZqx8Sp9kMUYGQSMmZlzYFsxapOLu2R6Vjg/5xt5RPYR+smI00YqmG52AuFRewJ4vQlVUvOeolxkYv2AXWOxZpcpSaor/wKzCkgXJmCIdwOd9cvIB/jJvF7iLrepPIUo8Rqvp8cLaLjyYwohGbDL2mncwq82C5lFAkpQcpXLp4yCVtw278Ts57PgL6uLwTrTPXfvOWiqMs/TwvR+QbYQZfDqoXYn7I0igLXxvkkKTWa9ulQYyVtmQR5pIfmcs2/jC6lsIm3Kp6ZxucJH7KnYXS1TwW2/TNlgPoFLKLQvc4/paeJLfaHmf2ZTqQv4EwfuYy68kPIeXhu1wqa6jwGw4Sy0zLkcjW9VuUxifqo9ADopy9Ap8RW7j4ufQ7oJ14RS0JSu/fZr28hJes2C47QCUyw2Bqp2OIBNDTpMsPiL6IDqFdy5+CKsrRVgqYjgU2ZHbDSV1sJNZx348ekZ/NeMyqmfUyhtmGm5dsqSl4B4nQuSaVwlRNLbaySRNukQN6YqF3xUjtQKad8GOeEeL7QaChgwKrc8Y= X-Forefront-PRVS: 0241D5F98C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(39450400003)(377424004)(24454002)(54534003)(377454003)(110136004)(38730400002)(65806001)(81166006)(305945005)(65826007)(6246003)(65956001)(230783001)(66066001)(229853002)(8676002)(189998001)(83506001)(47776003)(86362001)(42186005)(4001350100001)(31696002)(7736002)(575784001)(53936002)(31686004)(64126003)(6306002)(90366009)(2870700001)(53546006)(2351001)(2950100002)(3846002)(6916009)(2906002)(6116002)(76176999)(54356999)(50986999)(5660300001)(50466002)(33646002)(25786008)(6666003)(6486002)(36756003)(23746002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR07MB1266;H:[142.133.51.175];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;AM4PR07MB1266;23:4YlKtP6bMFTloenkih0CFHTgaVE2YvSX/QVSd?= =?Windows-1252?Q?6AVTYg38HXkDHqivHvVnyRyvIIt+EUz3G3a5SkGPcryvwdYDGiLwZoOT?= =?Windows-1252?Q?b9Nh7wH8MQbjWhiSz9ijDWdymi/DTYOtoqiDyeFHxuvLCFWPyhwbX9tr?= =?Windows-1252?Q?aCZpAUr6WQdY/R8P+waOmI8yBgfwkxYdIInCTFfbWvfGEdW9oz6zAEB0?= =?Windows-1252?Q?8WUvW1Cr6qNt33bXvZzwncUq3upCnJATjIGdPKZdS1hbshweyHYOoHGI?= =?Windows-1252?Q?kptGRuF2jPlWi4E+Ifg3zc/c4GWCTBSY6In8Magj+n/3K+4xWKOabu5v?= =?Windows-1252?Q?r3ZiMSRaizjh/ucYgG74EnCN10pHPq6YuZLvDm7DcWo4uvv/Wjd0p8qx?= =?Windows-1252?Q?4Z/0lXIrgk4urhuj4yMrta1Xovo5xxGU8nZN+8fYFJaGm6kkjNVxUC8H?= =?Windows-1252?Q?ZWCgSsOOAlgb5KB4baZ1Lzd7OENKapoEbykPOaMg8j7zCVXhYXTLpL8d?= =?Windows-1252?Q?dbfaRa30zZnyU9Si9RxE2ruB6K2j3He1Z/N7Q5CN+oYvg/YAQ54Pf+eO?= =?Windows-1252?Q?Y7QwHGbBZ9wQtIfwiq73mdXGxbf7KdOCcP+Oh2rLr1ai9YSqnsMJEH34?= =?Windows-1252?Q?fnLQVUlHMlS7CfSLV6qGlzOVoujGnimgIIR5Jsz39e2vYhFAzH18y3nZ?= =?Windows-1252?Q?G8ZqZ6553yu3WtHzRfEbPjzcgrcg+HegUT8trBgCwsIwMvxnDDKwzRkI?= =?Windows-1252?Q?R0RLhQMXn80YPr5msm2VoQhNqr0/5fxBUPd13xfwKJYeUWrP4GNgua23?= =?Windows-1252?Q?KhR8pWp+O7NU7wCt2OrHGWQYVPhms/v5uXnW5qw/S04jKHCjpIiTpHmi?= =?Windows-1252?Q?TPnFAMLT7XKuXE++Tsj44+pkpKnkZiha+brF340AfX6/fRNT5VV8iD40?= =?Windows-1252?Q?bWTCv0WfjY2ioeHoaaxrydGvaKeAwPhIGk27Dhi+AA7tZ9U4dUkN2RMk?= =?Windows-1252?Q?GaE/zbDsTYYP9Ogmp529bvl5eQc9KQGWeO2Zv1UYXf+bioQ6MeQB5Fd3?= =?Windows-1252?Q?moEZJNc0329tPQBKuLEwNGnw9r/uTGLA/JfwTEvuL5EOvkKvuyBR6VWa?= =?Windows-1252?Q?TUmatLmpbq/iFbKqTrmtBnAIGIV8MksLaglHek7di1DbbG5ereRcWR/F?= =?Windows-1252?Q?AAXUc81nh4/DecO4v1yQC207i44+VWKVzuSAdmQdscfDeKvY+zaWT9hN?= =?Windows-1252?Q?w7h43x2ELSP1K19UdFFVYGoeiudg8CXKTUopZWBNzxNUlJ0PKFY7PCra?= =?Windows-1252?Q?AU0fsnPmIZKToQzE+zAgVy9+CTspVet7FEIUIPy3mdHBwPnf4rywAEyY?= =?Windows-1252?Q?Ta6gH4fIFUCfFwgjs8SMgu23FczRB5hzw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;AM4PR07MB1266;6:kk+DjxnuNy/3YntyQ6QgYE6euxywXdlYuktJpvivL41P5yRHLGfjd8HHHsyGc7LqyYBaPzt3O6UP5+CCsWJdAYqY02wgk0IJlTSt8OkSr1WzVp61meqtAJoEU4gTdMFw6uo8HCORVRXItGuI5/tMBW/f5kndVVnZo4PBF9Bz4TIMkd8mtYF+98c/Uv45EmY7zc6BGjiWOBQ1NpKd7z7Y4m1Vxv6x2MPU5NL9zqyRpZwYLFMpdu80/no9YYJWR4HwKjybuYx1n+ODz9wFNgJDhbNaHxAG2zu8+dmmUKmSSxgQb9uulIUIMuMyp1gcr74qNeHwiguL1T5yBITvYsv9I8uUn/VenP7vXqZnUhiNgIXloERxKsZgjZNobkuCSEkXOcQKHXa66tNFBKY3sQAwpA==;5:G/++bjPxCIpe5C8x3agdn08Gb+Dzg+crOJdOl+sfj1fx0bS+hmJb6vAqd01Edb34tAvXSsnsgH8ZasQ+l6eBrvmFKz70eIFMNIBXZvlfqvtLpBM1k0x8y63ULbnPPkSbKeQyBdA04CtVQsTdxrSRT/DFUTSVqPK1WNG5j0LbWj0=;24:z4C6INyp4OUToH/kydy50EqNsCr38+ukpo1BQjmjMRI+6PNFTphnzsXQ5f+MO4ZsP6+q3qBXt9cB04UC8jxeF4AsKD5q9gQYeTeH5xSoBpY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM4PR07MB1266;7:zMPuKqvl7oSMdWdHoM/iuDhiby/ekOdeNSmLTfRjF5uH2ojGISrfWYtp/N6XjsT1oJGbKBqPTCMMkR2PsOt73jpdgPan2b5d9/N68nfL9q3f4Yhl/Q1pfJww+dofMyQn3WMpQ4edk+/PQRyUka+Dyf3NsdutAss9Sq32fGnqaPzVxxClpn9qIB29Y5ZLNkeSDJQmbN3O+YHaASA19VGrKwwaxwrRNAZbJGsFXFBNa5bTbEU2xm7KeO8OLGT9NvvSLlSf9MSyUohl+XYSEBhowMexVbuzNrvHsSo3PXgAlBrOIft2lD+l1gBzrm8t8wAy8i6Wy1tn0Ah/p8w+bMREqA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2017 19:12:14.4363 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR07MB1266 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00124.txt.bz2 Any chance that this can make it in before the branching? :) Thanks! Marc-André On 2017-03-02 09:55 AM, Marc-Andre Laperle wrote: > This change adds the MI equivalent for the "info sharedlibrary" > command. The command was already partially documented but ignored as > it was not implemented. The new MI command works similarly to the CLI > command, taking an optional regular expression as an argument and > outputting the library information. > > I included a test for the new command in mi-solib.exp. > > gdb/doc/ChangeLog: > > * gdb.texinfo (gdb/mi Symbol Query Commands): Document new MI > command file-list-shared-libraries > (GDB/MI Async Records): Update documentation of library-loaded with new > field. > > gdb/ChangeLog: > > * NEWS: Add an entry about new '-file-list-shared-libraries' command. > * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): > New function definition. > * mi/mi-cmds.c (mi_cmds): Add -file-list-shared-libraries command. > * mi/mi-cmds.h (mi_cmd_file_list_shared_libraries): > New function declaration. > * mi/mi-interp.c (mi_output_solib_attribs): New Function. > * mi/mi-interp.h: New file. > * solib.c (info_sharedlibrary_command): Replace for loop with > ALL_SO_LIBS macro > * solib.h (update_solib_list): New function declaration. > (so_list_head): Move macro. > * solist.h (ALL_SO_LIBS): New macro. > > gdb/testsuite/ChangeLog: > > * gdb.mi/mi-solib.exp (test_file_list_shared_libraries): > New procedure. > > Signed-off-by: Marc-Andre Laperle > --- > gdb/NEWS | 4 +++ > gdb/doc/gdb.texinfo | 34 ++++++++++++++++++----- > gdb/mi/mi-cmd-file.c | 57 +++++++++++++++++++++++++++++++++++++++ > gdb/mi/mi-cmds.c | 2 ++ > gdb/mi/mi-cmds.h | 1 + > gdb/mi/mi-interp.c | 36 +++++++++++++++++++------ > gdb/mi/mi-interp.h | 27 +++++++++++++++++++ > gdb/solib.c | 21 ++------------- > gdb/solib.h | 21 +++++++++++++++ > gdb/solist.h | 10 ++++++- > gdb/testsuite/gdb.mi/mi-solib.exp | 49 ++++++++++++++++++++++----------- > 11 files changed, 212 insertions(+), 50 deletions(-) > create mode 100644 gdb/mi/mi-interp.h > > diff --git a/gdb/NEWS b/gdb/NEWS > index 21e8cd3..a5c5e0d 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -68,6 +68,10 @@ flash-erase > Erases all the flash memory regions reported by the target. This is > equivalent to the CLI command flash-erase. > > +-file-list-shared-libraries > + List the shared libraries in the program. This is > + equivalent to the CLI command "info shared". > + > *** Changes in GDB 7.12 > > * GDB and GDBserver now build with a C++ compiler by default. > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo > index b9b4c82..4d68984 100644 > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -26545,8 +26545,8 @@ that thread. > > @item =library-loaded,... > Reports that a new library file was loaded by the program. This > -notification has 4 fields---@var{id}, @var{target-name}, > -@var{host-name}, and @var{symbols-loaded}. The @var{id} field is an > +notification has 5 fields---@var{id}, @var{target-name}, > +@var{host-name}, @var{symbols-loaded} and @var{ranges}. The @var{id} field is an > opaque identifier of the library. For remote debugging case, > @var{target-name} and @var{host-name} fields give the name of the > library file on the target, and on the host respectively. For native > @@ -26556,7 +26556,8 @@ and should not be relied on to convey any useful information. The > @var{thread-group} field, if present, specifies the id of the thread > group in whose context the library was loaded. If the field is > absent, it means the library was loaded in the context of all present > -thread groups. > +thread groups. The @var{ranges} field specifies the ranges of addresses belonging > +to this library. > > @item =library-unloaded,... > Reports that a library was unloaded by the program. This notification > @@ -31477,26 +31478,45 @@ The @value{GDBN} equivalent is @samp{info sources}. > (gdb) > @end smallexample > > -@ignore > @subheading The @code{-file-list-shared-libraries} Command > @findex -file-list-shared-libraries > > @subsubheading Synopsis > > @smallexample > - -file-list-shared-libraries > + -file-list-shared-libraries [ @var{regexp} ] > @end smallexample > > List the shared libraries in the program. > +With a regular expression @var{regexp}, only those libraries whose > +names match @var{regexp} are listed. > > @subsubheading @value{GDBN} Command > > -The corresponding @value{GDBN} command is @samp{info shared}. > +The corresponding @value{GDBN} command is @samp{info shared}. The fields > +have a similar meaning to the @code{=library-loaded} notification. > +The @code{ranges} field specifies the muliple segments belonging to this > +library. Each range has the following fields: > + > +@table @samp > +@item from > +The address defining the inclusive lower bound of the segment. > +@item to > +The address defining the exclusive upper bound of the segment. > +@end table > > @subsubheading Example > -N.A. > +@smallexample > +(gdb) > +-file-list-exec-source-files > +^done,shared-libraries=[ > +@{id="/lib/libfoo.so",target-name="/lib/libfoo.so",host-name="/lib/libfoo.so",symbols-loaded="1",thread-group="i1",ranges=[@{from="0x72815989",to="0x728162c0"@}]@}, > +@{id="/lib/libbar.so",target-name="/lib/libbar.so",host-name="/lib/libbar.so",symbols-loaded="1",thread-group="i1",ranges=[@{from="0x76ee48c0",to="0x76ee9160"@}]@}] > +(gdb) > +@end smallexample > > > +@ignore > @subheading The @code{-file-list-symbol-files} Command > @findex -file-list-symbol-files > > diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c > index 71e2845..a2ad392 100644 > --- a/gdb/mi/mi-cmd-file.c > +++ b/gdb/mi/mi-cmd-file.c > @@ -20,11 +20,15 @@ > #include "defs.h" > #include "mi-cmds.h" > #include "mi-getopt.h" > +#include "mi-interp.h" > #include "ui-out.h" > #include "symtab.h" > #include "source.h" > #include "objfiles.h" > #include "psymtab.h" > +#include "solib.h" > +#include "solist.h" > +#include "gdb_regex.h" > > /* Return to the client the absolute path and line number of the > current file being executed. */ > @@ -106,3 +110,56 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc) > > uiout->end (ui_out_type_list); > } > + > +/* See mi-cmds.h. */ > + > +void > +mi_cmd_file_list_shared_libraries (char *command, char **argv, int argc) > +{ > + struct ui_out *uiout = current_uiout; > + const char *pattern; > + struct so_list *so = NULL; > + struct gdbarch *gdbarch = target_gdbarch (); > + > + switch (argc) > + { > + case 0: > + pattern = NULL; > + break; > + case 1: > + pattern = argv[0]; > + break; > + default: > + error (_("Usage: -file-list-shared-libraries [REGEXP]")); > + } > + > + if (pattern != NULL) > + { > + const char *re_err = re_comp (pattern); > + > + if (re_err != NULL) > + error (_("Invalid regexp: %s"), re_err); > + } > + > + update_solib_list (1); > + > + /* Print the table header. */ > + struct cleanup *cleanup > + = make_cleanup_ui_out_list_begin_end (uiout, "shared-libraries"); > + > + ALL_SO_LIBS (so) > + { > + if (so->so_name[0] == '\0') > + continue; > + if (pattern != NULL && !re_exec (so->so_name)) > + continue; > + > + struct cleanup *tuple_clean_up > + = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); > + mi_output_solib_attribs (uiout, so); > + > + do_cleanups (tuple_clean_up); > + } > + > + do_cleanups (cleanup); > +} > diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c > index abb70bd..b7494ce 100644 > --- a/gdb/mi/mi-cmds.c > +++ b/gdb/mi/mi-cmds.c > @@ -115,6 +115,8 @@ static struct mi_cmd mi_cmds[] = > mi_cmd_file_list_exec_source_file), > DEF_MI_CMD_MI ("file-list-exec-source-files", > mi_cmd_file_list_exec_source_files), > + DEF_MI_CMD_MI ("file-list-shared-libraries", > + mi_cmd_file_list_shared_libraries), > DEF_MI_CMD_CLI ("file-symbol-file", "symbol-file", 1), > DEF_MI_CMD_MI ("gdb-exit", mi_cmd_gdb_exit), > DEF_MI_CMD_CLI_1 ("gdb-set", "set", 1, > diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h > index d0906e6..fcadfff 100644 > --- a/gdb/mi/mi-cmds.h > +++ b/gdb/mi/mi-cmds.h > @@ -70,6 +70,7 @@ extern mi_cmd_argv_ftype mi_cmd_exec_step; > extern mi_cmd_argv_ftype mi_cmd_exec_step_instruction; > extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file; > extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files; > +extern mi_cmd_argv_ftype mi_cmd_file_list_shared_libraries; > extern mi_cmd_argv_ftype mi_cmd_gdb_exit; > extern mi_cmd_argv_ftype mi_cmd_inferior_tty_set; > extern mi_cmd_argv_ftype mi_cmd_inferior_tty_show; > diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c > index aa76989..1a26818 100644 > --- a/gdb/mi/mi-interp.c > +++ b/gdb/mi/mi-interp.c > @@ -1119,6 +1119,33 @@ mi_on_resume (ptid_t ptid) > } > } > > +/* See mi-interp.h. */ > + > +void > +mi_output_solib_attribs (ui_out *uiout, struct so_list *solib) > +{ > + struct gdbarch *gdbarch = target_gdbarch (); > + > + uiout->field_string ("id", solib->so_original_name); > + uiout->field_string ("target-name", solib->so_original_name); > + uiout->field_string ("host-name", solib->so_name); > + uiout->field_int ("symbols-loaded", solib->symbols_loaded); > + if (!gdbarch_has_global_solist (target_gdbarch ())) > + uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num); > + > + struct cleanup *cleanup > + = make_cleanup_ui_out_list_begin_end (uiout, "ranges"); > + struct cleanup *tuple_clean_up > + = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); > + if (solib->addr_high != 0) > + { > + uiout->field_core_addr ("from", gdbarch, solib->addr_low); > + uiout->field_core_addr ("to", gdbarch, solib->addr_high); > + } > + do_cleanups (tuple_clean_up); > + do_cleanups (cleanup); > +} > + > static void > mi_solib_loaded (struct so_list *solib) > { > @@ -1140,14 +1167,7 @@ mi_solib_loaded (struct so_list *solib) > > uiout->redirect (mi->event_channel); > > - uiout->field_string ("id", solib->so_original_name); > - uiout->field_string ("target-name", solib->so_original_name); > - uiout->field_string ("host-name", solib->so_name); > - uiout->field_int ("symbols-loaded", solib->symbols_loaded); > - if (!gdbarch_has_global_solist (target_gdbarch ())) > - { > - uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num); > - } > + mi_output_solib_attribs (uiout, solib); > > uiout->redirect (NULL); > > diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h > new file mode 100644 > index 0000000..5b7b9f2 > --- /dev/null > +++ b/gdb/mi/mi-interp.h > @@ -0,0 +1,27 @@ > +/* MI Interpreter Definitions and Commands for GDB, the GNU debugger. > + > + Copyright (C) 2017 Free Software Foundation, Inc. > + > + This file is part of GDB. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see . */ > + > +#ifndef MI_INTERP_H > +#define MI_INTERP_H > + > +/* Output the shared object attributes to UIOUT. */ > + > +void mi_output_solib_attribs (ui_out *uiout, struct so_list *solib); > + > +#endif > diff --git a/gdb/solib.c b/gdb/solib.c > index 38737b6..af94383 100644 > --- a/gdb/solib.c > +++ b/gdb/solib.c > @@ -89,9 +89,6 @@ set_solib_ops (struct gdbarch *gdbarch, const struct target_so_ops *new_ops) > configuration needs to call set_solib_ops. */ > struct target_so_ops *current_target_so_ops; > > -/* List of known shared objects */ > -#define so_list_head current_program_space->so_list > - > /* Local function prototypes */ > > /* If non-empty, this is a search path for loading non-absolute shared library > @@ -749,21 +746,7 @@ solib_used (const struct so_list *const known) > return 0; > } > > -/* Synchronize GDB's shared object list with inferior's. > - > - Extract the list of currently loaded shared objects from the > - inferior, and compare it with the list of shared objects currently > - in GDB's so_list_head list. Edit so_list_head to bring it in sync > - with the inferior's new list. > - > - If we notice that the inferior has unloaded some shared objects, > - free any symbolic info GDB had read about those shared objects. > - > - Don't load symbolic info for any new shared objects; just add them > - to the list, and leave their symbols_loaded flag clear. > - > - If FROM_TTY is non-null, feel free to print messages about what > - we're doing. */ > +/* See solib.h. */ > > void > update_solib_list (int from_tty) > @@ -1105,7 +1088,7 @@ info_sharedlibrary_command (char *pattern, int from_tty) > > uiout->table_body (); > > - for (so = so_list_head; so; so = so->next) > + ALL_SO_LIBS (so) > { > struct cleanup *lib_cleanup; > > diff --git a/gdb/solib.h b/gdb/solib.h > index 1b46849..e91fb75 100644 > --- a/gdb/solib.h > +++ b/gdb/solib.h > @@ -28,6 +28,9 @@ struct program_space; > > #include "symfile-add-flags.h" > > +/* List of known shared objects */ > +#define so_list_head current_program_space->so_list > + > /* Called when we free all symtabs, to free the shared library information > as well. */ > > @@ -75,6 +78,24 @@ extern void no_shared_libraries (char *ignored, int from_tty); > extern void set_solib_ops (struct gdbarch *gdbarch, > const struct target_so_ops *new_ops); > > +/* Synchronize GDB's shared object list with inferior's. > + > + Extract the list of currently loaded shared objects from the > + inferior, and compare it with the list of shared objects currently > + in GDB's so_list_head list. Edit so_list_head to bring it in sync > + with the inferior's new list. > + > + If we notice that the inferior has unloaded some shared objects, > + free any symbolic info GDB had read about those shared objects. > + > + Don't load symbolic info for any new shared objects; just add them > + to the list, and leave their symbols_loaded flag clear. > + > + If FROM_TTY is non-null, feel free to print messages about what > + we're doing. */ > + > +extern void update_solib_list (int from_tty); > + > /* Return non-zero if NAME is the libpthread shared library. */ > > extern int libpthread_name_p (const char *name); > diff --git a/gdb/solist.h b/gdb/solist.h > index 9c7e965..6e2ab66 100644 > --- a/gdb/solist.h > +++ b/gdb/solist.h > @@ -24,6 +24,11 @@ > #include "symtab.h" > #include "gdb_bfd.h" > > +#define ALL_SO_LIBS(so) \ > + for (so = so_list_head; \ > + so != NULL; \ > + so = so->next) > + > /* Forward declaration for target specific link map information. This > struct is opaque to all but the target specific file. */ > struct lm_info; > @@ -74,7 +79,10 @@ struct so_list > > /* Record the range of addresses belonging to this shared library. > There may not be just one (e.g. if two segments are relocated > - differently); but this is only used for "info sharedlibrary". */ > + differently). This is used for "info sharedlibrary" and > + the MI command "-file-list-shared-libraries". The later has a format > + that supports outputting multiple segments once the related code > + supports them. */ > CORE_ADDR addr_low, addr_high; > }; > > diff --git a/gdb/testsuite/gdb.mi/mi-solib.exp b/gdb/testsuite/gdb.mi/mi-solib.exp > index 575cb97..ff933e7 100644 > --- a/gdb/testsuite/gdb.mi/mi-solib.exp > +++ b/gdb/testsuite/gdb.mi/mi-solib.exp > @@ -48,27 +48,46 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" > > mi_delete_breakpoints > mi_gdb_reinitialize_dir $srcdir/$subdir > -mi_gdb_reinitialize_dir $srcdir/$subdir > mi_gdb_load ${binfile} > > mi_load_shlibs $binfile_lib > > -mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \ > - "set stop-on-solib-events" > +proc_with_prefix test_stop_on_solib_events {} { > + mi_gdb_test "777-gdb-set stop-on-solib-events 1" "777\\^done" \ > + "set stop-on-solib-events" > > -# We use "run" rather than "-exec-run" here in order to test that CLI > -# commands still cause the correct MI output to be generated. > -mi_run_with_cli > + # We use "run" rather than "-exec-run" here in order to test that CLI > + # commands still cause the correct MI output to be generated. > + mi_run_with_cli > > -# Also test that the CLI solib event note is output. > -set test "CLI prints solib event" > -gdb_expect { > - -re "~\"Stopped due to shared library event \\(no libraries added or removed\\)\\\\n" { > - pass "$test" > - } > - timeout { > - fail "$test (timeout)" > + # Also test that the CLI solib event note is output. > + set test "CLI prints solib event" > + gdb_expect { > + -re "~\"Stopped due to shared library event \\(no libraries added or removed\\)\\\\n" { > + pass "$test" > + } > + timeout { > + fail "$test (timeout)" > + } > } > + > + mi_expect_stop solib-event .* .* .* .* .* "check for solib event" > + > + # Unset solib events to avoid interfering with other tests. > + mi_gdb_test "778-gdb-set stop-on-solib-events 0" "778\\^done" \ > + "unset stop-on-solib-events" > +} > + > +proc_with_prefix test_file_list_shared_libraries {} { > + global libname > + global binfile > + > + mi_continue_to main > + > + mi_gdb_test "222-file-list-shared-libraries" \ > + "222\\^done,shared-libraries=\\\[\{id=\".*${libname}.so\",target-name=\".*${libname}.so\",host-name=\".*${libname}.so\",symbols-loaded=\"1\",thread-group=\".*\",ranges=\\\[\{from=\".*\",to=\".*\"\}]\}]" \ > + "get the list of shared libraries" > } > > -mi_expect_stop solib-event .* .* .* .* .* "check for solib event" > +test_stop_on_solib_events > +test_file_list_shared_libraries