Patchwork Move declaration of vtbl_ptr_name to the header.

login
register
mail settings
Submitter Doug Evans via gdb-patches
Date Oct. 7, 2019, 6:27 p.m.
Message ID <20191007182712.26171-1-cbiesinger@google.com>
Download mbox | patch
Permalink /patch/34853/
State New
Headers show

Comments

Doug Evans via gdb-patches - Oct. 7, 2019, 6:27 p.m.
There are conflicting comments about whether this was
introduced in GCC 2.4.5 or GCC 2.6 and I don't know
which one is correct...

gdb/ChangeLog:

2019-10-07  Christian Biesinger  <cbiesinger@google.com>

	* c-lang.h (vtbl_ptr_name): Declare.
	* cp-valprint.c (vtbl_ptr_name): Remove "extern" now that we get
	it from the header.
	* stabsread.c (define_symbol): Remove declaration of vtbl_ptr_name.
---
 gdb/c-lang.h      | 6 ++++++
 gdb/cp-valprint.c | 2 +-
 gdb/stabsread.c   | 6 +-----
 3 files changed, 8 insertions(+), 6 deletions(-)
Tom Tromey - Oct. 7, 2019, 10:20 p.m.
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

Christian> There are conflicting comments about whether this was
Christian> introduced in GCC 2.4.5 or GCC 2.6 and I don't know
Christian> which one is correct...

Christian> 2019-10-07  Christian Biesinger  <cbiesinger@google.com>

Christian> 	* c-lang.h (vtbl_ptr_name): Declare.
Christian> 	* cp-valprint.c (vtbl_ptr_name): Remove "extern" now that we get
Christian> 	it from the header.
Christian> 	* stabsread.c (define_symbol): Remove declaration of vtbl_ptr_name.

Thanks.  This is ok.  Probably this is all dead code.

Tom
Doug Evans via gdb-patches - Oct. 7, 2019, 10:31 p.m.
On Mon, Oct 7, 2019 at 5:20 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Christian> There are conflicting comments about whether this was
> Christian> introduced in GCC 2.4.5 or GCC 2.6 and I don't know
> Christian> which one is correct...
>
> Christian> 2019-10-07  Christian Biesinger  <cbiesinger@google.com>
>
> Christian>      * c-lang.h (vtbl_ptr_name): Declare.
> Christian>      * cp-valprint.c (vtbl_ptr_name): Remove "extern" now that we get
> Christian>      it from the header.
> Christian>      * stabsread.c (define_symbol): Remove declaration of vtbl_ptr_name.
>
> Thanks.  This is ok.  Probably this is all dead code.

Thanks, pushed.

Christian

Patch

diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index d95df54c83..de291fa8f1 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -144,6 +144,12 @@  extern void cp_print_value_fields_rtti (struct type *,
 					const struct value_print_options *,
 					struct type **, int);
 
+/* gcc-2.6 or later (when using -fvtable-thunks)
+   emits a unique named type for a vtable entry.
+   Some gdb code depends on that specific name.  */
+
+extern const char vtbl_ptr_name[];
+
 extern int cp_is_vtbl_ptr_type (struct type *);
 
 extern int cp_is_vtbl_member (struct type *);
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index e73b0e27fa..04be4dc83b 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -56,7 +56,7 @@  static void cp_print_value (struct type *, struct type *,
 
 
 /* GCC versions after 2.4.5 use this.  */
-extern const char vtbl_ptr_name[] = "__vtbl_ptr_type";
+const char vtbl_ptr_name[] = "__vtbl_ptr_type";
 
 /* Return truth value for assertion that TYPE is of the type
    "pointer to virtual function".  */
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index da455da365..fa2521f1ca 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -42,6 +42,7 @@ 
 #include "gdb-demangle.h"
 #include "language.h"
 #include "target-float.h"
+#include "c-lang.h"
 #include "cp-abi.h"
 #include "cp-support.h"
 #include <ctype.h>
@@ -1259,11 +1260,6 @@  define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
       if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
 	{
-	  /* gcc-2.6 or later (when using -fvtable-thunks)
-	     emits a unique named type for a vtable entry.
-	     Some gdb code depends on that specific name.  */
-	  extern const char vtbl_ptr_name[];
-
 	  if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
 	       && strcmp (SYMBOL_LINKAGE_NAME (sym), vtbl_ptr_name))
 	      || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FUNC)