From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 695 invoked by alias); 4 Oct 2019 03:01:19 -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 670 invoked by uid 89); 4 Oct 2019 03:01:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Oct 2019 03:01:14 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 96C291E0A4; Thu, 3 Oct 2019 23:01:12 -0400 (EDT) Subject: Re: [PATCH 3/3] gdb/mi: Add new commands -symbol-info-{functions,variables,types} To: Andrew Burgess , gdb-patches References: From: Simon Marchi Message-ID: <32bedef4-727e-ad35-318b-8ebc18924583@simark.ca> Date: Fri, 04 Oct 2019 03:01:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-10/txt/msg00150.txt.bz2 On 2019-09-26 7:09 p.m., Andrew Burgess wrote: > Add new MI commands -symbol-info-functions, -symbol-info-variables, > and -symbol-info-types which correspond to the CLI commands 'info > functions', 'info variables', and 'info types' respectively. Hi Andrew, The first thing I tried was to run it on GDB itself and run "-symbol-info-functions" by itself. Apparently, it tries to list all functions in the program :). I think we need to be careful with that, as it would be really easy for a debug session to become unresponsive. Imagine an IDE that has a little box to search symbols by name. The user while debugging a big program, types "e", which generates this MI command: -symbol-info-functions --name "e" This would essentially hang the debug session while GDB expands all the symtabs with at least a function with "e" in its name. It would take a huge amount of time and memory. I don't know how easy it would be to implement, but for these cases, a "--max-results N" switch, which would stop the search early, might useful. Note that the same happens if you type "info functions" in the CLI. But at least, when using the CLI interactively, you can ctrl-C, which front-ends don't typically do. Also, since this output is meant to be consumed by a front-end, it would be interesting to have the details of the symbols in separate fields. For example, for variables, have the type and name in separate fields. This gives front-ends more freedom on how to display them. For functions, I would even see (maybe not in this patch though) a list of parameters with their names and types. Of course, we can always start with something basic and add fields as we go. I didn't really look at the implementation, since it's getting a bit late, but: > diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h > index 91ce4cd4070..5fa4fafbb05 100644 > --- a/gdb/mi/mi-cmds.h > +++ b/gdb/mi/mi-cmds.h > @@ -94,6 +94,9 @@ extern mi_cmd_argv_ftype mi_cmd_stack_list_locals; > extern mi_cmd_argv_ftype mi_cmd_stack_list_variables; > extern mi_cmd_argv_ftype mi_cmd_stack_select_frame; > extern mi_cmd_argv_ftype mi_cmd_symbol_list_lines; > +extern mi_cmd_argv_ftype mi_cmd_symbol_info_functions; > +extern mi_cmd_argv_ftype mi_cmd_symbol_info_variables; > +extern mi_cmd_argv_ftype mi_cmd_symbol_info_types; The last two are not in alphabetical order (in the .c as well). Simon