From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100267 invoked by alias); 1 Mar 2017 15:50:50 -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 100249 invoked by uid 89); 1 Mar 2017 15:50:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 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= X-HELO: sesbmg23.ericsson.net Received: from sesbmg23.ericsson.net (HELO sesbmg23.ericsson.net) (193.180.251.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Mar 2017 15:50:45 +0000 Received: from ESESSHC024.ericsson.se (Unknown_Domain [153.88.183.90]) by (Symantec Mail Security) with SMTP id A3.56.32680.3DDE6B85; Wed, 1 Mar 2017 16:50:43 +0100 (CET) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.90) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 1 Mar 2017 16:50:23 +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 DB5PR07MB1271.eurprd07.prod.outlook.com (2a01:111:e400:599a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.2; Wed, 1 Mar 2017 15:50:21 +0000 Subject: Re: [Patch v3] Add -file-list-shared-libraries MI command To: References: <20170228220729.28635-1-marc-andre.laperle@ericsson.com> From: =?UTF-8?Q?Marc-Andr=c3=a9_Laperle?= Message-ID: Date: Wed, 01 Mar 2017 15:50: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: <20170228220729.28635-1-marc-andre.laperle@ericsson.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: DM5PR19CA0003.namprd19.prod.outlook.com (2603:10b6:3:151::13) To DB5PR07MB1271.eurprd07.prod.outlook.com (2a01:111:e400:599a::21) X-MS-Office365-Filtering-Correlation-Id: bd9b6fcb-88ea-400b-3841-08d460baab41 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB5PR07MB1271; X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1271;3:r9YirSzGwkwrs7/gITUwC8CFy5HDsskgLTSYKy15QKqJjLZBo9NvlXBTDsPDF0kEDxp25puZari+P5vahgf3hgBgLk9RqGlOsLkiaBNmszHA3fo8/eOFot11p0CJdFmKbbhrfEVZO6GWFPwjYI4gKg5/ZX0NCDewcDAzPb5UFe32jJle6Ex0woPxZJhn+/1iur0lEjfPqRGET4BB1PGKOK34KnKbevErpBng2KNe507WzxTgBXaq6QA2KmS3HTEQ74EChgUTZbZ0jLfsbED8Uw==;25:GTIq8EXjnBsMdiP+zaGLo49VUrDxS515A2/Z2APjN1NF3LhHLKT7/mG6xERHqgxljqKOwUOxSvbKXu4T+i0YnRxXiakdUKaK8cQ3z6sg/GU0bzvuWgw0Zs989plcrq37CQ5KTzS4ZO213eEMop76p3fD1wo96yv1CCqpJr6q1Q2uepd9oTRqW2NwQgLxFxrpkwN7QBzwcu74PShO7acWH2FazvrdRLzNTc9YWcHMu9frwztDLevR/NUZ9TIV+3fSHXSWKwGguBTlty2chupcwIX6icS26hmWrvXk0eYCh34Br3GDlyRIVXvQYyph2Ag0bqcqCcA/+tQ72E339k4gwuuSOCenunc1LLHkczZ3PYW9FYU3T7FBvwydSLX2ICRek3Ab12KWGZMVzysNYmA7QCKTmC7w4Z5H7sBy6wxgnwJY4Ic4cvv/6FrXCQzC4kyXok3i8oWrwvhgX20tNwXDLg== X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1271;31:nZk1i8R/6VtfDrtoDdgCynmuUsnFzTfftITx92kZIAB0E6vb9QI5Rjb64WqEopZzV2J218eceNFc5fh4EUv88I4n0fgwwtIKPQphO5Ju22uxtIRbdBqh3kdDBG4GLHsIp3liUJA9M5by0jmvq1Bm010eVGKzX/2KbvU/dIe4BR+/UCSDF/h0MiJ2t/Hvk5BO7Mvkf5bgl9OZev1BCc16NCHyMiegmi5I+Lve4d6yX/xKf5eUoVzjiU4YpAimls9qYC9IO574rWafUThoBvLUIA==;20:lhRz+fzVd0OZppXC6lf5Guxs77h1fhqgyS+fSP3RtEqY+zgh5hWUzyIdBvHK5s0SPv7BM6rFowfq1UyUQdJqhepjlA08u2OzZj4o5f23xG3IH45yM6Aupc7cCrlajs/WeUO9ubTtV7DptGy5ZAeVFcxdQFV8oRFHlgZjs3jr0ULlnNZn+GvBg5PhqSP/mMPoxq4P7gfSFsfBs6xNNmsgKApZqHJFLT8qQl6iZox82vhQtv2f1V/14lCy2MUKlhbiPXFYqaIjVexY08bw9FOlT+75FNnck24mizgvp09hTP4q7SP5LSFmG01zkbw6hr7prGVzT78wyg1lwbsjyNqNg2qktRSw0zdTd3XAepDgQLq83r3yREl1CStiPlr+t34X2nMSWRVfkpCvFKgw4YCtp92S1m8Lx+IchgpzEp5qvBy4jDTy1R4lT+hxgYUWVzqofdtDNkrZhqxToeTqnHNOm2XoD24dH7Zc4DRrvW4di11JxjVaog5beO/spfXFq8rg 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)(20161123555025)(20161123558025)(20161123560025)(20161123564025)(20161123562025)(6072148);SRVR:DB5PR07MB1271;BCL:0;PCL:0;RULEID:;SRVR:DB5PR07MB1271; X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1271;4:FRLm4/qHVR17OmdFrQ/kRRrz1/OKj1df9YNCEJlrsEbZH6h+ZaQECmdoIOg4+hfWVn6HXJZfTlGpzY5g7PyKQ8slsktlVUJT2kd+b8BbVaD/G9MYEsMXYASQBZ09FyBc8xlkjZUyNkIbDEr67xUvrje8hjht6RJnqXl7Yf08M5QkhNJjB5Z3EYRDtB5BH11pgKvxpHtyv2J8+QP2HB1xpMTxgQN/Q/lwQhTPs58hRiMs7D9FBTYtsFQeqSRBJ2Q4QRD7w0jSXF0naGYxHiYHSLBwFup02yARzKxEx/Nm2FYBLtZOijB/FcvdNATdvNN/NU/7z/KNOxsUvOWqjkD5/bC+1o2TG72y2jiZC1oJfOC281NAQvD5vjxHgTDnbx8TznDTP6tpURdy0d0YUR4DOhYdQ4KKFLdxxD3k6LMQEIJvfue4QP7ytdsDR6aPvhwJs2dlb5dF6wxI8DyQt13X1GcxELEScTmTN7hhx0k+EoLvIdW7hNvoUsUgeivdnVw3w+uP7TMksPcbK+7hvPye8HT9Pkjz48R233KAbew3ssoGFdCKcSDfM8pjF5mdkB/rdhYZbFXuchbSXt/CXrrtCUgxepjVKOcPH1PXTwMqI/nt1nOOrY2ZAAA/Yb+xpIPM4n9tYrc9hwyn6C+rzRHUJykeAtFSwy+KZOnzqEUxi7sF8i2BFe/yJhVwvrfxcQsVYDx4UhUszSsfwKkymEvS6qSxwBTDitYLDRU+fXAR722vLP6vqidzIhycGo0fMYcjOa8mXAgRgici0GP9KwXk8jqQWg2Xmda6zBxYxsQh5gE= X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(39450400003)(377424004)(24454002)(377454003)(66066001)(6246003)(92566002)(38730400002)(81166006)(65956001)(23746002)(83506001)(65806001)(230783001)(8676002)(110136004)(229853002)(575784001)(86362001)(3846002)(5660300001)(6306002)(31686004)(31696002)(53936002)(6116002)(36756003)(42186005)(53546006)(2950100002)(50466002)(6486002)(2351001)(54356999)(2870700001)(2906002)(50986999)(6916009)(305945005)(76176999)(7736002)(33646002)(6666003)(189998001)(450100001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR07MB1271;H:[142.133.51.175];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DB5PR07MB1271;23:CWHVshZdY4XIWGrGHSAbcgOBXBGHjiwZyHY9H?= =?Windows-1252?Q?5dh5pG7zIJX6wlDfxAlEidRqpOtsTivBCIPEgULT86wArRAXP3SXyOcS?= =?Windows-1252?Q?nSu5iVB4P924xSVTq1TwNLrS3f/Nvn7b7dSdDlqjPJgrDPV0mg09huFQ?= =?Windows-1252?Q?HXwUA/TlVb4en2jbSoy4n3IkAwF0WwZNWjtRQbrX0nbdKmd3JqaxQeZQ?= =?Windows-1252?Q?vOhwTq8p+04j5Lt6GsL4k7BvM2CivCyQ50XdH/zq4AP/ZYfh2MDJOl5M?= =?Windows-1252?Q?X2bqjp7pfMGrQG0yftKPifjV79wSW/bZMW2VFDdyscdjMb5diQ5IMc8E?= =?Windows-1252?Q?GIpJ7wfPAmAQGmHYWwsGL+BwBu7GIuB9R1jWCvG5GgynZrzQllk7jw8Z?= =?Windows-1252?Q?ORwWw7VVFQ2ZCC1TtrQ8weLAMy0yFHJ8BQRp2z3DBRQSL/ePXLC9PrOG?= =?Windows-1252?Q?cnlEd4XS9BimgWhoG8rUTk7qvq14hsuuKPoAxEBIbuc4yyQFvEvmRL3u?= =?Windows-1252?Q?g4c+soqs7qguMc2L2Z5/8XWjHpRMJzEMKcy9EY5Yb4hzI+/vUaQ8dyVn?= =?Windows-1252?Q?lIA92no4/3z7ND+wxTDyeySCoiWs/2nc+HSuKNpffof4lF9jWRUcE1p4?= =?Windows-1252?Q?lONWwD01ie2ipcZnUlpMYneJckOEqAeKSGi6P3C45LUxlKh3oEUxX8ek?= =?Windows-1252?Q?aOKXOnP30yrQEfQygHQ+D9Lt6mLGAnhQq9zLZtqolFZusZwdN4B4gkFW?= =?Windows-1252?Q?G+d9HxFx4QLILW7VFQ1IMccW9YU4Y5G7GIaeG3IN+BfWlsS8G1fceN3S?= =?Windows-1252?Q?26YJB2HuVqgcpd+PaxC0Tz3Irhi6vg+4XHoPtcreTP+Q6KQtIYLq9Pxh?= =?Windows-1252?Q?vTb2uRQhLzcQq6RDXbswxILwvKdAZk5XmkdF3rH0HTyJ80awvqJ/37f8?= =?Windows-1252?Q?rtMaGn3ZtKOpEZA8dlYHuouze2MF10op0MxM4LQapPOxsQ0NtpG+rSd8?= =?Windows-1252?Q?6C0vVjR/UP6SOn+BDKrxTmVfSDq+o3NbYPdGz0mMqkgnoWuzjEnOcNu5?= =?Windows-1252?Q?KgZ9ZKcNdRokEzy+TfK88cBXkeqwK87knj3jJpF2AsPVp2BTDix8WU11?= =?Windows-1252?Q?eDavfFIo154K8Q45plMmGpRa8XHw7z38mX2IaRsZkCYKwpxCq6cwUntE?= =?Windows-1252?Q?Roh+xjzJwv07W75dXbnv0U9iNZNRlCuVcwKa2JcLI/evQFA8V+zUjrGF?= =?Windows-1252?Q?/ncs38o9SdCDLWe27lKo3HK4aRqPcOMc9dJnrM=3D?= X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1271;6:czlzjszTiU+JxewvjOhvG4LFhcYEAhUyvBU+2a26QsfoC/HBGIuLq//ZaWDtxTyDamV/Xh5UUEunrFzABd36Bi6A4DujkExx5XCkCE98RhD8WK1kv7CtSbwsczeLNR7mGFds5S1bCwOPGnrm7Tj5OqNcqzRkIbH9yvMYAYStGo0jMa2+dKrMpn6T9a0o0nVmmL6Tsy5sRVZwBeJkvpgC5aMD3+2aWW4dEnyr/rC/l3J14JWUBJMnbcDBXeaiZjfcdTzmPU/Mt52AEGeor3V7jeJ6ZT9bSAvfyFiNVnIF880+zIXTVLRA/2aYfUGPjUMdOtMqGBmfXJXzEIGUJSfTn56RMvLeXCc58x+A643W1r1oaLo8rC7NBKG2DA70Nl5xzK0ptVof5elrzL7ThWbORA==;5:m0QKwUZvnG720Wh1PaGM9M8TcPc8N6x6TDHDfROmIwfjdKFBxS3J4GLWFl5lp13/62YNYLgu7pSyMj8I6GZolG4i/3fbmWOcCQTiGDFa8rdr6BgR3ICT/KUXG4wOfi80XUqGqwFENZ8xBeaRzBDdMw==;24:4ZqMqe/xQYUQ/6WJJLnFS5lzxve70qD5Cpndp4HLQi3OpxKYQ93HOjtXVnbM+ll/87/5fEDP/qHEmya0N/3WBkD+mYK0qJ/y/ryb9I580aM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB5PR07MB1271;7:B5Z3Al40U8CSsb611iTT59eFWspJE7GXyaLiXSZkrKBaqPkqHv36stokx3WOt8xDFOHcAdHtznIv4d5RAGvCeDE9pOng+mm8dpsyXvwF2XNPL/GGrlWvEAXcPlIJgvShstP20DFAM496Jo/5lhD/dRgdOfnfbE5dx4b/hkMVewz1n0M6WD8H+U6333/Ib42SiB7BWhJJQ8ugm16ppBVVrnHhyl0nV6tWxXynbh6BKsIphcaE9FFMQSKIaBVhnT8jNrNEB5+1jZM/CMcjdwypI8vstA8tj67z6UlqlfrJ67qse6u814Xpa3IrFcsVK2bFrTgn7FCNC+wZAvEV0P6Y3Q== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 15:50:21.5063 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR07MB1271 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00005.txt.bz2 This patch should address all previous comments. Regards, Marc-André On 2017-02-28 05:07 PM, 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..097a608 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 than 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