* [RFA 2/2] Make names in gdbtypes.h,symtab.h const char *.
@ 2012-02-02 22:52 Doug Evans
2012-02-06 17:09 ` Doug Evans
2012-02-06 19:07 ` Tom Tromey
0 siblings, 2 replies; 3+ messages in thread
From: Doug Evans @ 2012-02-02 22:52 UTC (permalink / raw)
To: gdb-patches
Hi.
The changes to these two files involve a teensy bit of extra
work beyond simple mechanical changes.
This patch requires the main patch in
http://sourceware.org/ml/gdb-patches/2012-02/msg00043.html
Ok to check in?
2012-02-02 Doug Evans <dje@google.com>
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
Index: coffread.c
===================================================================
RCS file: /cvs/src/src/gdb/coffread.c,v
retrieving revision 1.125
diff -u -p -r1.125 coffread.c
--- coffread.c 4 Jan 2012 08:17:00 -0000 1.125
+++ coffread.c 2 Feb 2012 21:55:41 -0000
@@ -1455,10 +1455,11 @@ patch_type (struct type *type, struct ty
if (TYPE_NAME (real_target))
{
+ /* The previous copy of TYPE_NAME is allocated by
+ process_coff_symbol. */
if (TYPE_NAME (target))
- xfree (TYPE_NAME (target));
- TYPE_NAME (target) = concat (TYPE_NAME (real_target),
- (char *) NULL);
+ xfree ((char*) TYPE_NAME (target));
+ TYPE_NAME (target) = xstrdup (TYPE_NAME (real_target));
}
}
@@ -1486,7 +1487,7 @@ patch_opaque_types (struct symtab *s)
&& TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR
&& TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0)
{
- char *name = SYMBOL_LINKAGE_NAME (real_sym);
+ const char *name = SYMBOL_LINKAGE_NAME (real_sym);
int hash = hashname (name);
struct symbol *sym, *prev;
@@ -1675,7 +1676,7 @@ process_coff_symbol (struct coff_symbol
}
else
TYPE_NAME (SYMBOL_TYPE (sym)) =
- concat (SYMBOL_LINKAGE_NAME (sym), (char *) NULL);
+ xstrdup (SYMBOL_LINKAGE_NAME (sym));
}
/* Keep track of any type which points to empty structured
Index: stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.142
diff -u -p -r1.142 stabsread.c
--- stabsread.c 8 Jan 2012 21:02:45 -0000 1.142
+++ stabsread.c 2 Feb 2012 21:55:41 -0000
@@ -1173,7 +1173,7 @@ define_symbol (CORE_ADDR valu, char *str
NULL, objfile);
if (msym != NULL)
{
- char *new_name = gdbarch_static_transform_name
+ const char *new_name = gdbarch_static_transform_name
(gdbarch, SYMBOL_LINKAGE_NAME (sym));
SYMBOL_SET_LINKAGE_NAME (sym, new_name);
@@ -1367,7 +1367,7 @@ define_symbol (CORE_ADDR valu, char *str
NULL, objfile);
if (msym != NULL)
{
- char *new_name = gdbarch_static_transform_name
+ const char *new_name = gdbarch_static_transform_name
(gdbarch, SYMBOL_LINKAGE_NAME (sym));
SYMBOL_SET_LINKAGE_NAME (sym, new_name);
@@ -2232,10 +2232,11 @@ rs6000_builtin_type (int typenum, struct
\f
/* This page contains subroutines of read_type. */
-/* Replace *OLD_NAME with the method name portion of PHYSNAME. */
+/* Wrapper around method_name_from_physname to flag a complaint
+ if there is an error. */
-static void
-update_method_name_from_physname (char **old_name, const char *physname)
+static char *
+stabs_method_name_from_physname (const char *physname)
{
char *method_name;
@@ -2245,16 +2246,10 @@ update_method_name_from_physname (char *
{
complaint (&symfile_complaints,
_("Method has bad physname %s\n"), physname);
- return;
+ return NULL;
}
- if (strcmp (*old_name, method_name) != 0)
- {
- xfree (*old_name);
- *old_name = method_name;
- }
- else
- xfree (method_name);
+ return method_name;
}
/* Read member function stabs info for C++ classes. The form of each member
@@ -2687,14 +2682,24 @@ read_member_functions (struct field_info
- in -gstabs instead of -gstabs+
- or for static methods, which are output as a function type
instead of a method type. */
+ char *new_method_name =
+ stabs_method_name_from_physname (sublist->fn_field.physname);
- update_method_name_from_physname (&new_fnlist->fn_fieldlist.name,
- sublist->fn_field.physname);
+ if (new_method_name != NULL
+ && strcmp (new_method_name,
+ new_fnlist->fn_fieldlist.name) != 0)
+ {
+ new_fnlist->fn_fieldlist.name = new_method_name;
+ xfree (main_fn_name);
+ }
+ else
+ xfree (new_method_name);
}
else if (has_destructor && new_fnlist->fn_fieldlist.name[0] != '~')
{
new_fnlist->fn_fieldlist.name =
- concat ("~", main_fn_name, (char *)NULL);
+ obconcat (&objfile->objfile_obstack,
+ "~", main_fn_name, (char *)NULL);
xfree (main_fn_name);
}
else if (!has_stub)
@@ -2711,6 +2716,7 @@ read_member_functions (struct field_info
new_fnlist->fn_fieldlist.name
= obsavestring (dem_opname, strlen (dem_opname),
&objfile->objfile_obstack);
+ xfree (main_fn_name);
}
new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
@@ -2753,7 +2759,7 @@ read_cpp_abbrev (struct field_info *fip,
struct objfile *objfile)
{
char *p;
- char *name;
+ const char *name;
char cpp_abbrev;
struct type *context;
@@ -3266,7 +3272,7 @@ read_tilde_fields (struct field_info *fi
i >= TYPE_N_BASECLASSES (t);
--i)
{
- char *name = TYPE_FIELD_NAME (t, i);
+ const char *name = TYPE_FIELD_NAME (t, i);
if (!strncmp (name, vptr_name, sizeof (vptr_name) - 2)
&& is_cplus_marker (name[sizeof (vptr_name) - 2]))
@@ -3406,8 +3412,8 @@ attach_fields_to_type (struct field_info
static void
complain_about_struct_wipeout (struct type *type)
{
- char *name = "";
- char *kind = "";
+ const char *name = "";
+ const char *kind = "";
if (TYPE_TAG_NAME (type))
{
@@ -4545,7 +4551,7 @@ cleanup_undefined_types_1 (void)
struct pending *ppt;
int i;
/* Name of the type, without "struct" or "union". */
- char *typename = TYPE_TAG_NAME (*type);
+ const char *typename = TYPE_TAG_NAME (*type);
if (typename == NULL)
{
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFA 2/2] Make names in gdbtypes.h,symtab.h const char *.
2012-02-02 22:52 [RFA 2/2] Make names in gdbtypes.h,symtab.h const char * Doug Evans
@ 2012-02-06 17:09 ` Doug Evans
2012-02-06 19:07 ` Tom Tromey
1 sibling, 0 replies; 3+ messages in thread
From: Doug Evans @ 2012-02-06 17:09 UTC (permalink / raw)
To: gdb-patches
On Thu, Feb 2, 2012 at 2:52 PM, Doug Evans <dje@google.com> wrote:
> Hi.
>
> The changes to these two files involve a teensy bit of extra
> work beyond simple mechanical changes.
> This patch requires the main patch in
> http://sourceware.org/ml/gdb-patches/2012-02/msg00043.html
>
> Ok to check in?
>
> 2012-02-02 Doug Evans <dje@google.com>
>
> * coffread.c (patch_type): Add (char*) cast to xfree parameter.
> Use xstrdup.
> (process_coff_symbol): Use xstrdup.
> * stabsread.c (stabs_method_name_from_physname): Renamed from
> update_method_name_from_physname. Change result type from void
> to char *. All callers updated.
> (read_member_functions): In has_destructor case, store name in objfile
> obstack instead of malloc space. In !has_stub case, fix mem leak.
+ the main patch: http://sourceware.org/ml/gdb-patches/2012-02/msg00043.html
Ping.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA 2/2] Make names in gdbtypes.h,symtab.h const char *.
2012-02-02 22:52 [RFA 2/2] Make names in gdbtypes.h,symtab.h const char * Doug Evans
2012-02-06 17:09 ` Doug Evans
@ 2012-02-06 19:07 ` Tom Tromey
1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2012-02-06 19:07 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
>>>>> "Doug" == Doug Evans <dje@google.com> writes:
Doug> The changes to these two files involve a teensy bit of extra
Doug> work beyond simple mechanical changes.
Doug> This patch requires the main patch in
Doug> http://sourceware.org/ml/gdb-patches/2012-02/msg00043.html
FWIW this seems fine to me.
Doug> @@ -1455,10 +1455,11 @@ patch_type (struct type *type, struct ty
Doug> if (TYPE_NAME (real_target))
Doug> {
Doug> + /* The previous copy of TYPE_NAME is allocated by
Doug> + process_coff_symbol. */
Doug> if (TYPE_NAME (target))
Doug> - xfree (TYPE_NAME (target));
Doug> - TYPE_NAME (target) = concat (TYPE_NAME (real_target),
Doug> - (char *) NULL);
Doug> + xfree ((char*) TYPE_NAME (target));
Doug> + TYPE_NAME (target) = xstrdup (TYPE_NAME (real_target));
Doug> }
Doug> }
The old code here is pretty bad :(
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-02-06 19:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-02 22:52 [RFA 2/2] Make names in gdbtypes.h,symtab.h const char * Doug Evans
2012-02-06 17:09 ` Doug Evans
2012-02-06 19:07 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox