From patchwork Sat Jan 19 12:33:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 31126 Received: (qmail 128502 invoked by alias); 19 Jan 2019 12:33:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 128387 invoked by uid 89); 19 Jan 2019 12:33:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:find_pc X-HELO: mailsec102.isp.belgacom.be Received: from mailsec102.isp.belgacom.be (HELO mailsec102.isp.belgacom.be) (195.238.20.98) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 Jan 2019 12:33:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1547901208; x=1579437208; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QuIsxvUACJmlu17Qv9JZJPLJe29XTdKWmLF6QSyhclg=; b=YFk+BGX8aqCuuizUS0HnWeT2VZUqpLnwZ0bj5tvhiSidhV7cwN0Y1+fF KC/YCzbw9T0Mhc1oDnE44ymoN0UNAg==; Received: from 184.205-67-87.adsl-dyn.isp.belgacom.be (HELO md.home) ([87.67.205.184]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 19 Jan 2019 13:33:21 +0100 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFAv3 3/3] Make symtab.c better styled. Date: Sat, 19 Jan 2019 13:33:15 +0100 Message-Id: <20190119123315.5758-4-philippe.waroquiers@skynet.be> In-Reply-To: <20190119123315.5758-1-philippe.waroquiers@skynet.be> References: <20190119123315.5758-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes Note that print_msymbol_info does not (yet?) print data msymbol using variable_name_style, as otherwise 'info variables' would show the non debugging symbols in variable name style, but 'real' variables would be not styled. 2019-01-19 Philippe Waroquiers * symtab.h (struct minimal_symbol data_p): New const method. (struct minimal_symbol text_p): Likewise. * symtab.c (output_source_filename): Use file name style to print file name. (print_symbol_info): Likewise. (print_msymbol_info): Use address style to print addresses. Use function name style to print executable text symbols. (expand_symtab_containing_pc): Use data_p. (find_pc_sect_compunit_symtab): Likewise. --- gdb/symtab.c | 55 +++++++++++++++++++++++++++++++++++++--------------- gdb/symtab.h | 8 ++++++++ 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/gdb/symtab.c b/gdb/symtab.c index a2bd4dd54d..ad2a1599a3 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -41,6 +41,7 @@ #include "p-lang.h" #include "addrmap.h" #include "cli/cli-utils.h" +#include "cli/cli-style.h" #include "fnmatch.h" #include "hashtab.h" #include "typeprint.h" @@ -311,6 +312,31 @@ compunit_language (const struct compunit_symtab *cust) return SYMTAB_LANGUAGE (symtab); } +/* See symtab.h. */ + +bool +minimal_symbol::data_p () const +{ + return type == mst_data + || type == mst_bss + || type == mst_abs + || type == mst_file_data + || type == mst_file_bss; +} + +/* See symtab.h. */ + +bool +minimal_symbol::text_p () const +{ + return type == mst_text + || type == mst_text_gnu_ifunc + || type == mst_data_gnu_ifunc + || type == mst_slot_got_plt + || type == mst_solib_trampoline + || type == mst_file_text; +} + /* See whether FILENAME matches SEARCH_NAME using the rule that we advertise to the user. (The manual's description of linespecs describes what we advertise). Returns true if they match, false @@ -1039,12 +1065,7 @@ expand_symtab_containing_pc (CORE_ADDR pc, struct obj_section *section) necessary because we loop based on texthigh and textlow, which do not include the data ranges. */ msymbol = lookup_minimal_symbol_by_pc_section (pc, section); - if (msymbol.minsym - && (MSYMBOL_TYPE (msymbol.minsym) == mst_data - || MSYMBOL_TYPE (msymbol.minsym) == mst_bss - || MSYMBOL_TYPE (msymbol.minsym) == mst_abs - || MSYMBOL_TYPE (msymbol.minsym) == mst_file_data - || MSYMBOL_TYPE (msymbol.minsym) == mst_file_bss)) + if (msymbol.minsym && msymbol.minsym->data_p ()) return; for (objfile *objfile : current_program_space->objfiles ()) @@ -2879,12 +2900,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) we call find_pc_sect_psymtab which has a similar restriction based on the partial_symtab's texthigh and textlow. */ msymbol = lookup_minimal_symbol_by_pc_section (pc, section); - if (msymbol.minsym - && (MSYMBOL_TYPE (msymbol.minsym) == mst_data - || MSYMBOL_TYPE (msymbol.minsym) == mst_bss - || MSYMBOL_TYPE (msymbol.minsym) == mst_abs - || MSYMBOL_TYPE (msymbol.minsym) == mst_file_data - || MSYMBOL_TYPE (msymbol.minsym) == mst_file_bss)) + if (msymbol.minsym && msymbol.minsym->data_p ()) return NULL; /* Search all symtabs for the one whose file contains our address, and which @@ -4168,7 +4184,7 @@ output_source_filename (const char *name, data->first = 0; wrap_here (""); - fputs_filtered (name, gdb_stdout); + fputs_styled (name, file_name_style.style (), gdb_stdout); } /* A callback for map_partial_symbol_filenames. */ @@ -4620,7 +4636,7 @@ print_symbol_info (enum search_domain kind, if (filename_cmp (last, s_filename) != 0) { fputs_filtered ("\nFile ", gdb_stdout); - fputs_filtered (s_filename, gdb_stdout); + fputs_styled (s_filename, file_name_style.style (), gdb_stdout); fputs_filtered (":\n", gdb_stdout); } @@ -4667,8 +4683,15 @@ print_msymbol_info (struct bound_minimal_symbol msymbol) else tmp = hex_string_custom (BMSYMBOL_VALUE_ADDRESS (msymbol), 16); - printf_filtered ("%s %s\n", - tmp, MSYMBOL_PRINT_NAME (msymbol.minsym)); + fputs_styled (tmp, address_style.style (), gdb_stdout); + fputs_filtered (" ", gdb_stdout); + if (msymbol.minsym->text_p ()) + fputs_styled (MSYMBOL_PRINT_NAME (msymbol.minsym), + function_name_style.style (), + gdb_stdout); + else + fputs_filtered (MSYMBOL_PRINT_NAME (msymbol.minsym), gdb_stdout); + fputs_filtered ("\n", gdb_stdout); } /* This is the guts of the commands "info functions", "info types", and diff --git a/gdb/symtab.h b/gdb/symtab.h index 57ed2c0948..e3e7177afa 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -686,6 +686,14 @@ struct minimal_symbol the `next' pointer for the demangled hash table. */ struct minimal_symbol *demangled_hash_next; + +/* True if this symbol is of some data type. */ + + bool data_p () const; + + /* True if MSYMBOL is of some text type. */ + + bool text_p () const; }; #define MSYMBOL_TARGET_FLAG_1(msymbol) (msymbol)->target_flag_1