From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 78EEA3986406 for ; Fri, 15 May 2020 15:07:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 78EEA3986406 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x432.google.com with SMTP id l11so4006638wru.0 for ; Fri, 15 May 2020 08:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RR0C7lFwt4LDHMxgU7VOGu3/t31EU+66QE7QzvJP4sU=; b=KOcHf4uVSBkLtvBpPIXHuuc9aTZooUNrtcW7id9SoqJcpojQv8i1UMxsAsuZJ4dkFH 83cjem1oIzWbYdc7yUrCDUm/17ORAKXxWsphiK1B1q9XSYZG7Z0l2fJLUryQJZwmShgZ LR6EmGm8wMP/S/j+W4fEVhwXBUB1rNZsRwaRZGStb1F8i2lnyy8JwToFS2v7pSUd5fiH XG3SemsFLN4MdBseUIcYtsEtVsm62OcVW4Ht5r7TBK7QQK/73fNY8HN3iP/aF8nE2iJu 8Twrq1t08Dc1902uPVsZng9avjoGmjiXxlKlg062eMrSF8KW7bdFhR+c3d7UrqI7YkYP 3oZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RR0C7lFwt4LDHMxgU7VOGu3/t31EU+66QE7QzvJP4sU=; b=lXh7YQtFHXiUlBSECxtlIoFva8oaGR0fSylF7tumU+MftRpAx6XUxeWp/tF1hvV8/U pMvXZ9G1wLV47X4jaF8ylIBcTYTESp4ZBf8nzp3VJn1hz/6kSiy9BgbjqQcpQ7wPV1uV 8OCX5hsV37CbSvkXI/9lPjoYA6+W/rEGA+Hj8S9+rww+xIziLn+CGBROGQxRWGIqVAYC QmV4udo4YkuhQbo2EtEqWVGnjUtIbOqWxtQNxR0Fs+BAbk5bZBlQTtH5n6QqtZ9tDKwb +hHkM3sv+7FqBYtLDgGesV2xS0bx3IoIvWnAQXEuntww4vcStw/dNyXvUwHiHUIru4wN VeBQ== X-Gm-Message-State: AOAM531vAbDukS9ZnX/a9mVZyoOE8g0BErwIXCMLjipDTcnVijiGLmkW EiSmOFBGnKlgAndcqdUh8SP5uCxdBRQ= X-Google-Smtp-Source: ABdhPJzSuaLAB/2cxCjexVTAfkT12RCC2vtL3aHkLDh7UTg1TFvVPabJhpIEw1o9/9OCqpFn5xfWjA== X-Received: by 2002:adf:de12:: with SMTP id b18mr4802426wrm.275.1589555238645; Fri, 15 May 2020 08:07:18 -0700 (PDT) Received: from localhost (host86-128-12-16.range86-128.btcentralplus.com. [86.128.12.16]) by smtp.gmail.com with ESMTPSA id v126sm4171923wmb.4.2020.05.15.08.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 08:07:18 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: [PATCHv2 10/13] gdb: Convert language la_sniff_from_mangled_name field to a method Date: Fri, 15 May 2020 16:06:49 +0100 Message-Id: <7e336f3485c9b35f85757786d784c8c0e2fa1a48.1589555077.git.andrew.burgess@embecosm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2020 15:07:27 -0000 This commit changes the language_data::la_sniff_from_mangled_name function pointer member variable into a member function of language_defn. Previously the la_sniff_from_mangled_name pointer was NULL for some languages, however, all uses of this function pointer were through the function language_sniff_from_mangled_name which provided a default implementation. This default implementation now becomes the implementation in the base class language_defn, which is then overridden as required in various language sub-classes. There should be no user visible changes after this commit. gdb/ChangeLog: * ada-lang.c (ada_sniff_from_mangled_name): Delete function, implementation moves to... (ada_language::sniff_from_mangled_name): ...here. Update return type. (ada_language_data): Delete la_sniff_from_mangled_name initializer. * c-lang.c (c_language_data): Likewise. (cplus_language_data): Likewise. (cplus_language::sniff_from_mangled_name): New member function, implementation taken from gdb_sniff_from_mangled_name. (asm_language_data): Delete la_sniff_from_mangled_name initializer. (minimal_language_data): Likewise. * cp-support.c (gdb_sniff_from_mangled_name): Delete, implementation moves to cplus_language::sniff_from_mangled_name. * cp-support.h (gdb_sniff_from_mangled_name): Delete declaration. * d-lang.c (d_sniff_from_mangled_name): Delete, implementation moves to... (d_language::sniff_from_mangled_name): ...here. (d_language_data): Delete la_sniff_from_mangled_name initializer. * f-lang.c (f_language_data): Likewise. * go-lang.c (go_sniff_from_mangled_name): Delete, implementation moves to... (go_language::sniff_from_mangled_name): ...here. (go_language_data): Delete la_sniff_from_mangled_name initializer. * language.c (language_sniff_from_mangled_name): Delete. (unknown_language_data): Delete la_sniff_from_mangled_name initializer. (auto_language_data): Likewise. * language.h (language_data): Delete la_sniff_from_mangled_name field. (language_defn::sniff_from_mangled_name): New function. (language_sniff_from_mangled_name): Delete declaration. * m2-lang.c (m2_language_data): Delete la_sniff_from_mangled_name field. * objc-lang.c (objc_sniff_from_mangled_name): Delete, implementation moves to... (objc_language::sniff_from_mangled_name): ...here. (objc_language_data): Delete la_sniff_from_mangled_name initializer. * opencl-lang.c (opencl_language_data): Likewise. * p-lang.c (pascal_language_data): Likewise. * rust-lang.c (rust_sniff_from_mangled_name): Delete, implementation moves to... (rust_language::sniff_from_mangled_name): ...here. (rust_language_data): Delete la_sniff_from_mangled_name initializer. * symtab.c (symbol_find_demangled_name): Call sniff_from_mangled_name member function. --- gdb/ChangeLog | 51 +++++++++++++++++++++++++++++++ gdb/ada-lang.c | 78 +++++++++++++++++++++++------------------------ gdb/c-lang.c | 12 +++++--- gdb/cp-support.c | 9 ------ gdb/cp-support.h | 4 --- gdb/d-lang.c | 18 +++++------ gdb/f-lang.c | 1 - gdb/go-lang.c | 18 +++++------ gdb/language.c | 19 ------------ gdb/language.h | 44 +++++++++++++------------- gdb/m2-lang.c | 1 - gdb/objc-lang.c | 18 +++++------ gdb/opencl-lang.c | 1 - gdb/p-lang.c | 1 - gdb/rust-lang.c | 20 +++++------- gdb/symtab.c | 4 +-- 16 files changed, 152 insertions(+), 147 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index f2b941969f3..7ad53956c45 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1375,45 +1375,6 @@ ada_la_decode (const char *encoded, int options) return xstrdup (ada_decode (encoded).c_str ()); } -/* Implement la_sniff_from_mangled_name for Ada. */ - -static int -ada_sniff_from_mangled_name (const char *mangled, char **out) -{ - std::string demangled = ada_decode (mangled); - - *out = NULL; - - if (demangled != mangled && demangled[0] != '<') - { - /* Set the gsymbol language to Ada, but still return 0. - Two reasons for that: - - 1. For Ada, we prefer computing the symbol's decoded name - on the fly rather than pre-compute it, in order to save - memory (Ada projects are typically very large). - - 2. There are some areas in the definition of the GNAT - encoding where, with a bit of bad luck, we might be able - to decode a non-Ada symbol, generating an incorrect - demangled name (Eg: names ending with "TB" for instance - are identified as task bodies and so stripped from - the decoded name returned). - - Returning 1, here, but not setting *DEMANGLED, helps us get a - little bit of the best of both worlds. Because we're last, - we should not affect any of the other languages that were - able to demangle the symbol before us; we get to correctly - tag Ada symbols as such; and even if we incorrectly tagged a - non-Ada symbol, which should be rare, any routing through the - Ada language should be transparent (Ada tries to behave much - like C/C++ with non-Ada symbols). */ - return 1; - } - - return 0; -} - /* Arrays */ @@ -13964,7 +13925,6 @@ extern const struct language_data ada_language_data = true, /* la_store_sym_names_in_linkage_form_p */ ada_lookup_symbol_nonlocal, /* Looking up non-local symbols. */ ada_la_decode, /* Language specific symbol demangler */ - ada_sniff_from_mangled_name, NULL, /* Language specific class_name_from_physname */ ada_op_print_tab, /* expression operators for printing */ @@ -14102,6 +14062,44 @@ class ada_language : public language_defn return true; } + + /* See language.h. */ + bool sniff_from_mangled_name (const char *mangled, + char **out) const override + { + std::string demangled = ada_decode (mangled); + + *out = NULL; + + if (demangled != mangled && demangled[0] != '<') + { + /* Set the gsymbol language to Ada, but still return 0. + Two reasons for that: + + 1. For Ada, we prefer computing the symbol's decoded name + on the fly rather than pre-compute it, in order to save + memory (Ada projects are typically very large). + + 2. There are some areas in the definition of the GNAT + encoding where, with a bit of bad luck, we might be able + to decode a non-Ada symbol, generating an incorrect + demangled name (Eg: names ending with "TB" for instance + are identified as task bodies and so stripped from + the decoded name returned). + + Returning true, here, but not setting *DEMANGLED, helps us get + a little bit of the best of both worlds. Because we're last, + we should not affect any of the other languages that were + able to demangle the symbol before us; we get to correctly + tag Ada symbols as such; and even if we incorrectly tagged a + non-Ada symbol, which should be rare, any routing through the + Ada language should be transparent (Ada tries to behave much + like C/C++ with non-Ada symbols). */ + return true; + } + + return false; + } }; /* Single instance of the Ada language class. */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 8cdcfd9b63f..be09d45478e 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -914,7 +914,6 @@ extern const struct language_data c_language_data = true, /* la_store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ NULL, /* Language specific symbol demangler */ - NULL, NULL, /* Language specific class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ @@ -1017,7 +1016,6 @@ extern const struct language_data cplus_language_data = false, /* la_store_sym_names_in_linkage_form_p */ cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ gdb_demangle, /* Language specific symbol demangler */ - gdb_sniff_from_mangled_name, cp_class_name_from_physname, /* Language specific class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ @@ -1130,6 +1128,14 @@ class cplus_language : public language_defn { return cp_search_name_hash (name); } + + /* See language.h. */ + bool sniff_from_mangled_name (const char *mangled, + char **demangled) const override + { + *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI); + return *demangled != NULL; + } }; /* The single instance of the C++ language class. */ @@ -1168,7 +1174,6 @@ extern const struct language_data asm_language_data = true, /* la_store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ NULL, /* Language specific symbol demangler */ - NULL, NULL, /* Language specific class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ @@ -1236,7 +1241,6 @@ extern const struct language_data minimal_language_data = true, /* la_store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ NULL, /* Language specific symbol demangler */ - NULL, NULL, /* Language specific class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ diff --git a/gdb/cp-support.c b/gdb/cp-support.c index bc9e8d4eda5..955e0ae82f7 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1608,15 +1608,6 @@ gdb_demangle (const char *name, int options) /* See cp-support.h. */ -int -gdb_sniff_from_mangled_name (const char *mangled, char **demangled) -{ - *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI); - return *demangled != NULL; -} - -/* See cp-support.h. */ - unsigned int cp_search_name_hash (const char *search_name) { diff --git a/gdb/cp-support.h b/gdb/cp-support.h index 6ca898315bb..7c948b212cb 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -191,8 +191,4 @@ extern struct cmd_list_element *maint_cplus_cmd_list; char *gdb_demangle (const char *name, int options); -/* Like gdb_demangle, but suitable for use as la_sniff_from_mangled_name. */ - -int gdb_sniff_from_mangled_name (const char *mangled, char **demangled); - #endif /* CP_SUPPORT_H */ diff --git a/gdb/d-lang.c b/gdb/d-lang.c index c6ee6a231e6..23b9464cb58 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -56,15 +56,6 @@ d_demangle (const char *symbol, int options) return gdb_demangle (symbol, options | DMGL_DLANG); } -/* la_sniff_from_mangled_name implementation for D. */ - -static int -d_sniff_from_mangled_name (const char *mangled, char **demangled) -{ - *demangled = d_demangle (mangled, 0); - return *demangled != NULL; -} - /* Table mapping opcodes into strings for printing operators and precedences of the operators. */ static const struct op_print d_op_print_tab[] = @@ -166,7 +157,6 @@ extern const struct language_data d_language_data = false, /* la_store_sym_names_in_linkage_form_p */ d_lookup_symbol_nonlocal, d_demangle, /* Language specific symbol demangler. */ - d_sniff_from_mangled_name, NULL, /* Language specific class_name_from_physname. */ d_op_print_tab, /* Expression operators for printing. */ @@ -254,6 +244,14 @@ class d_language : public language_defn lai->bool_type_symbol = "bool"; lai->bool_type_default = builtin->builtin_bool; } + + /* See language.h. */ + bool sniff_from_mangled_name (const char *mangled, + char **demangled) const override + { + *demangled = d_demangle (mangled, 0); + return *demangled != NULL; + } }; /* Single instance of the D language class. */ diff --git a/gdb/f-lang.c b/gdb/f-lang.c index a2df46a8b4a..804b2823f31 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -623,7 +623,6 @@ extern const struct language_data f_language_data = and there is no DW_AT_producer available for inferiors with only the ELF symbols to check the mangling kind. */ NULL, /* Language specific symbol demangler */ - NULL, NULL, /* Language specific class_name_from_physname */ f_op_print_tab, /* expression operators for printing */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index a74458d572a..eb89dc598b7 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -396,15 +396,6 @@ go_demangle (const char *mangled_name, int options) return result; } -/* la_sniff_from_mangled_name for Go. */ - -static int -go_sniff_from_mangled_name (const char *mangled, char **demangled) -{ - *demangled = go_demangle (mangled, 0); - return *demangled != NULL; -} - /* Given a Go symbol, return its package or NULL if unknown. Space for the result is malloc'd, caller must free. */ @@ -551,7 +542,6 @@ extern const struct language_data go_language_data = false, /* la_store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, go_demangle, /* Language specific symbol demangler. */ - go_sniff_from_mangled_name, NULL, /* Language specific class_name_from_physname. */ go_op_print_tab, /* Expression operators for printing. */ @@ -628,6 +618,14 @@ class go_language : public language_defn lai->bool_type_symbol = "bool"; lai->bool_type_default = builtin->builtin_bool; } + + /* See language.h. */ + bool sniff_from_mangled_name (const char *mangled, + char **demangled) const override + { + *demangled = go_demangle (mangled, 0); + return *demangled != NULL; + } }; /* Single instance of the Go language class. */ diff --git a/gdb/language.c b/gdb/language.c index 425081a64c8..2b46452f3b8 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -595,23 +595,6 @@ language_demangle (const struct language_defn *current_language, return NULL; } -/* See language.h. */ - -int -language_sniff_from_mangled_name (const struct language_defn *lang, - const char *mangled, char **demangled) -{ - gdb_assert (lang != NULL); - - if (lang->la_sniff_from_mangled_name == NULL) - { - *demangled = NULL; - return 0; - } - - return lang->la_sniff_from_mangled_name (mangled, demangled); -} - /* Return class name from physname or NULL. */ char * language_class_name_from_physname (const struct language_defn *lang, @@ -827,7 +810,6 @@ extern const struct language_data unknown_language_data = true, /* store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ unk_lang_demangle, /* Language specific symbol demangler */ - NULL, unk_lang_class_name, /* Language specific class_name_from_physname */ unk_op_print_tab, /* expression operators for printing */ @@ -891,7 +873,6 @@ extern const struct language_data auto_language_data = false, /* store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ unk_lang_demangle, /* Language specific symbol demangler */ - NULL, unk_lang_class_name, /* Language specific class_name_from_physname */ unk_op_print_tab, /* expression operators for printing */ diff --git a/gdb/language.h b/gdb/language.h index 1829be8085b..78721de8e59 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -318,22 +318,6 @@ struct language_data /* Return demangled language symbol, or NULL. */ char *(*la_demangle) (const char *mangled, int options); - /* Demangle a symbol according to this language's rules. Unlike - la_demangle, this does not take any options. - - *DEMANGLED will be set by this function. - - If this function returns 0, then *DEMANGLED must always be set - to NULL. - - If this function returns 1, the implementation may set this to - a xmalloc'd string holding the demangled form. However, it is - not required to. The string, if any, is owned by the caller. - - The resulting string should be of the form that will be - installed into a symbol. */ - int (*la_sniff_from_mangled_name) (const char *mangled, char **demangled); - /* Return class name of a mangled method name or NULL. */ char *(*la_class_name_from_physname) (const char *physname); @@ -511,6 +495,27 @@ struct language_defn : language_data /* Hash the given symbol search name. */ virtual unsigned int search_name_hash (const char *name) const; + /* Demangle a symbol according to this language's rules. Unlike + la_demangle, this does not take any options. + + *DEMANGLED will be set by this function. + + If this function returns false, then *DEMANGLED must always be set + to NULL. + + If this function returns true, the implementation may set this to + a xmalloc'd string holding the demangled form. However, it is + not required to. The string, if any, is owned by the caller. + + The resulting string should be of the form that will be + installed into a symbol. */ + virtual bool sniff_from_mangled_name (const char *mangled, + char **demangled) const + { + *demangled = nullptr; + return false; + } + /* List of all known languages. */ static const struct language_defn *languages[nr_languages]; }; @@ -664,13 +669,6 @@ extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc); extern char *language_demangle (const struct language_defn *current_language, const char *mangled, int options); -/* A wrapper for la_sniff_from_mangled_name. The arguments and result - are as for the method. */ - -extern int language_sniff_from_mangled_name (const struct language_defn *lang, - const char *mangled, - char **demangled); - /* Return class name from physname, or NULL. */ extern char *language_class_name_from_physname (const struct language_defn *, const char *physname); diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index bd1058c9a96..e27e11d9b52 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -376,7 +376,6 @@ extern const struct language_data m2_language_data = false, /* la_store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ NULL, /* Language specific symbol demangler */ - NULL, NULL, /* Language specific class_name_from_physname */ m2_op_print_tab, /* expression operators for printing */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index afbb1fbed73..3082a5d058a 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -281,15 +281,6 @@ objc_demangle (const char *mangled, int options) return NULL; /* Not an objc mangled name. */ } -/* la_sniff_from_mangled_name for ObjC. */ - -static int -objc_sniff_from_mangled_name (const char *mangled, char **demangled) -{ - *demangled = objc_demangle (mangled, 0); - return *demangled != NULL; -} - /* Determine if we are currently in the Objective-C dispatch function. If so, get the address of the method function that the dispatcher would call and use that as the function to step into instead. Also @@ -391,7 +382,6 @@ extern const struct language_data objc_language_data = false, /* la_store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ objc_demangle, /* Language specific symbol demangler */ - objc_sniff_from_mangled_name, NULL, /* Language specific class_name_from_physname */ objc_op_print_tab, /* Expression operators for printing */ @@ -422,6 +412,14 @@ class objc_language : public language_defn { c_language_arch_info (gdbarch, lai); } + + /* See language.h. */ + bool sniff_from_mangled_name (const char *mangled, + char **demangled) const override + { + *demangled = objc_demangle (mangled, 0); + return *demangled != NULL; + } }; /* Single instance of the class representing the Objective-C language. */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 3643320acd8..41598a0bec3 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1051,7 +1051,6 @@ extern const struct language_data opencl_language_data = false, /* la_store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ NULL, /* Language specific symbol demangler */ - NULL, NULL, /* Language specific class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 7e7b6ff7b83..448637cbada 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -407,7 +407,6 @@ extern const struct language_data pascal_language_data = false, /* la_store_sym_names_in_linkage_form_p */ basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ NULL, /* Language specific symbol demangler */ - NULL, NULL, /* Language specific class_name_from_physname */ pascal_op_print_tab, /* expression operators for printing */ 1, /* c-style arrays */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index cf9dce76e2d..c9531579e8f 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -2016,17 +2016,6 @@ rust_lookup_symbol_nonlocal (const struct language_defn *langdef, -/* la_sniff_from_mangled_name for Rust. */ - -static int -rust_sniff_from_mangled_name (const char *mangled, char **demangled) -{ - *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI); - return *demangled != NULL; -} - - - /* la_watch_location_expression for Rust. */ static gdb::unique_xmalloc_ptr @@ -2083,7 +2072,6 @@ extern const struct language_data rust_language_data = false, /* la_store_sym_names_in_linkage_form_p */ rust_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ gdb_demangle, /* Language specific symbol demangler */ - rust_sniff_from_mangled_name, NULL, /* Language specific class_name_from_physname */ c_op_print_tab, /* expression operators for printing */ @@ -2148,6 +2136,14 @@ class rust_language : public language_defn lai->bool_type_default = types[rust_primitive_bool]; lai->string_char_type = types[rust_primitive_u8]; } + + /* See language.h. */ + bool sniff_from_mangled_name (const char *mangled, + char **demangled) const override + { + *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI); + return *demangled != NULL; + } }; /* Single instance of the Rust language class. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 6ad78933501..6f1788c3916 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -807,7 +807,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, { const struct language_defn *lang = language_def (gsymbol->language ()); - language_sniff_from_mangled_name (lang, mangled, &demangled); + lang->sniff_from_mangled_name (mangled, &demangled); return demangled; } @@ -816,7 +816,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, enum language l = (enum language) i; const struct language_defn *lang = language_def (l); - if (language_sniff_from_mangled_name (lang, mangled, &demangled)) + if (lang->sniff_from_mangled_name (mangled, &demangled)) { gsymbol->m_language = l; return demangled; -- 2.25.4