- [expr-cumulative] using-directive: Fix memory leak (Sami Wagiaalla).
This commit is contained in:
parent
7b8bd72d9a
commit
862a58ce4d
|
@ -0,0 +1,214 @@
|
|||
FSF GDB variant is at:
|
||||
http://sourceware.org/ml/gdb-patches/2010-03/msg00789.html
|
||||
|
||||
commit 56b45f494f647360f9d6ff84f12f59c08cbe05af
|
||||
Author: Sami Wagiaalla <swagiaal@redhat.com>
|
||||
Date: Mon Mar 29 16:08:58 2010 -0400
|
||||
|
||||
Fix using_directive memory leak.
|
||||
|
||||
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
|
||||
index ff2c9b1..35e4663 100644
|
||||
--- a/gdb/buildsym.c
|
||||
+++ b/gdb/buildsym.c
|
||||
@@ -387,6 +387,7 @@ finish_block (struct symbol *symbol, struct pending **listhead,
|
||||
}
|
||||
|
||||
block_set_using (block, using_directives, &objfile->objfile_obstack);
|
||||
+ using_directives = NULL;
|
||||
|
||||
record_pending_block (objfile, block, opblock);
|
||||
|
||||
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
|
||||
index 6325ead..c6df91f 100644
|
||||
--- a/gdb/cp-namespace.c
|
||||
+++ b/gdb/cp-namespace.c
|
||||
@@ -120,7 +120,8 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
|
||||
anonymous namespace. So add symbols in it to the
|
||||
namespace given by the previous component if there is
|
||||
one, or to the global namespace if there isn't. */
|
||||
- cp_add_using_directive (dest, src, NULL, "", 0);
|
||||
+ cp_add_using_directive (dest, src, NULL, "", 0,
|
||||
+ &SYMBOL_SYMTAB (symbol)->objfile->objfile_obstack);
|
||||
}
|
||||
/* The "+ 2" is for the "::". */
|
||||
previous_component = next_component + 2;
|
||||
@@ -132,11 +133,17 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
|
||||
}
|
||||
|
||||
/* Add a using directive to using_list. If the using directive in question
|
||||
- has already been added, don't add it twice. */
|
||||
+ has already been added, don't add it twice.
|
||||
+ Create a new struct using_direct which imports the namespace SRC into the
|
||||
+ scope DEST. ALIAS is the name of the imported namespace in the current
|
||||
+ scope. If ALIAS is NULL then the namespace is known by its original name.
|
||||
+ The arguments are copied into newly allocated memory so they can be
|
||||
+ temporaries. */
|
||||
|
||||
void
|
||||
cp_add_using_directive (const char *dest, const char *src, const char *alias,
|
||||
- const char *declaration, const int line_number)
|
||||
+ const char *declaration, const int line_number,
|
||||
+ struct obstack *obstack)
|
||||
{
|
||||
struct using_direct *current;
|
||||
struct using_direct *new;
|
||||
@@ -146,12 +153,26 @@ cp_add_using_directive (const char *dest, const char *src, const char *alias,
|
||||
for (current = using_directives; current != NULL; current = current->next)
|
||||
{
|
||||
if (strcmp (current->import_src, src) == 0
|
||||
- && strcmp (current->import_dest, dest) == 0)
|
||||
+ && strcmp (current->import_dest, dest) == 0
|
||||
+ && ((alias == NULL && current->alias == NULL)
|
||||
+ || (alias != NULL && current->alias != NULL
|
||||
+ && strcmp (alias, current->alias) == 0)))
|
||||
return;
|
||||
}
|
||||
|
||||
- using_directives = cp_add_using (dest, src, alias, declaration,
|
||||
- line_number, using_directives);
|
||||
+ new = OBSTACK_ZALLOC (obstack, struct using_direct);
|
||||
+
|
||||
+ new->import_src = obsavestring (src, strlen (src), obstack);
|
||||
+ new->import_dest = obsavestring (dest, strlen (dest), obstack);
|
||||
+
|
||||
+ if (alias != NULL)
|
||||
+ new->alias = obsavestring (alias, strlen (alias), obstack);
|
||||
+
|
||||
+ new->declaration = obsavestring (declaration, strlen (declaration), obstack);
|
||||
+ new->line_number = line_number;
|
||||
+
|
||||
+ new->next = using_directives;
|
||||
+ using_directives = new;
|
||||
|
||||
}
|
||||
|
||||
@@ -203,42 +224,6 @@ cp_is_anonymous (const char *namespace)
|
||||
!= NULL);
|
||||
}
|
||||
|
||||
-/* Create a new struct using direct which imports the namespace SRC
|
||||
- into the scope DEST. ALIAS is the name of the imported namespace
|
||||
- in the current scope. If ALIAS is NULL then the
|
||||
- namespace is known by its original name.
|
||||
-
|
||||
- Set its next member in the linked list to NEXT; allocate all memory
|
||||
- using xmalloc. It copies the strings, so NAME can be a temporary
|
||||
- string. */
|
||||
-
|
||||
-struct using_direct *
|
||||
-cp_add_using (const char *dest,
|
||||
- const char *src,
|
||||
- const char *alias,
|
||||
- const char *declaration,
|
||||
- const int line_number,
|
||||
- struct using_direct *next)
|
||||
-{
|
||||
- struct using_direct *retval;
|
||||
-
|
||||
- retval = xmalloc (sizeof (struct using_direct));
|
||||
- retval->import_src = savestring (src, strlen (src));
|
||||
- retval->import_dest = savestring (dest, strlen (dest));
|
||||
-
|
||||
- if (alias != NULL)
|
||||
- retval->alias = savestring (alias, strlen (alias));
|
||||
- else
|
||||
- retval->alias = NULL;
|
||||
-
|
||||
- retval->declaration = savestring (declaration, strlen (declaration));
|
||||
- retval->line_number = line_number;
|
||||
- retval->next = next;
|
||||
- retval->searched = 0;
|
||||
-
|
||||
- return retval;
|
||||
-}
|
||||
-
|
||||
/* The C++-specific version of name lookup for static and global
|
||||
names. This makes sure that names get looked for in all namespaces
|
||||
that are in scope. NAME is the natural name of the symbol that
|
||||
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
|
||||
index 57aa5e5..41f17fe 100644
|
||||
--- a/gdb/cp-support.h
|
||||
+++ b/gdb/cp-support.h
|
||||
@@ -101,14 +101,8 @@ extern void cp_add_using_directive (const char *dest,
|
||||
const char *src,
|
||||
const char *alias,
|
||||
const char *declaration,
|
||||
- const int line_number);
|
||||
-
|
||||
-extern struct using_direct *cp_add_using (const char *dest,
|
||||
- const char *src,
|
||||
- const char *alias,
|
||||
- const char *declaration,
|
||||
- const int line_number,
|
||||
- struct using_direct *next);
|
||||
+ const int line_number,
|
||||
+ struct obstack *obstack);
|
||||
|
||||
extern void cp_initialize_namespace (void);
|
||||
|
||||
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
|
||||
index e3a780e..b73f444 100644
|
||||
--- a/gdb/dwarf2read.c
|
||||
+++ b/gdb/dwarf2read.c
|
||||
@@ -3563,12 +3563,12 @@ read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
|
||||
}
|
||||
}
|
||||
|
||||
- using_directives = cp_add_using (import_prefix,
|
||||
- canonical_name,
|
||||
- import_alias,
|
||||
- imported_declaration,
|
||||
- line_number,
|
||||
- using_directives);
|
||||
+ cp_add_using_directive (import_prefix,
|
||||
+ canonical_name,
|
||||
+ import_alias,
|
||||
+ imported_declaration,
|
||||
+ line_number,
|
||||
+ &cu->objfile->objfile_obstack);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -5703,7 +5703,12 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
|
||||
if (is_anonymous)
|
||||
{
|
||||
const char *previous_prefix = determine_prefix (die, cu);
|
||||
- cp_add_using_directive (previous_prefix, TYPE_NAME (type), NULL, "", dwarf2_read_decl_line(die, cu));
|
||||
+ cp_add_using_directive (previous_prefix,
|
||||
+ TYPE_NAME (type),
|
||||
+ NULL,
|
||||
+ "",
|
||||
+ dwarf2_read_decl_line(die, cu),
|
||||
+ &objfile->objfile_obstack);
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/gdb/testsuite/gdb.cp/gdb2384-base.cc b/gdb/testsuite/gdb.cp/gdb2384-base.cc
|
||||
index 09ed04e..b58f30d 100644
|
||||
--- a/gdb/testsuite/gdb.cp/gdb2384-base.cc
|
||||
+++ b/gdb/testsuite/gdb.cp/gdb2384-base.cc
|
||||
@@ -23,6 +23,8 @@ base::base (int _x)
|
||||
{
|
||||
}
|
||||
|
||||
+using namespace B;
|
||||
+
|
||||
int
|
||||
base::meth ()
|
||||
{
|
||||
diff --git a/gdb/testsuite/gdb.cp/gdb2384-base.h b/gdb/testsuite/gdb.cp/gdb2384-base.h
|
||||
index b09701e..981943c 100644
|
||||
--- a/gdb/testsuite/gdb.cp/gdb2384-base.h
|
||||
+++ b/gdb/testsuite/gdb.cp/gdb2384-base.h
|
||||
@@ -16,6 +16,10 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
+namespace B{
|
||||
+ int x;
|
||||
+}
|
||||
+
|
||||
class base
|
||||
{
|
||||
public:
|
9
gdb.spec
9
gdb.spec
|
@ -36,7 +36,7 @@ Version: 7.1
|
|||
|
||||
# The release always contains a leading reserved number, start it at 1.
|
||||
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
|
||||
Release: 2%{?_with_upstream:.upstream}%{dist}
|
||||
Release: 3%{?_with_upstream:.upstream}%{dist}
|
||||
|
||||
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
|
||||
Group: Development/Debuggers
|
||||
|
@ -441,6 +441,9 @@ Patch434: gdb-pie-1of6-reprelinked-bin.patch
|
|||
Patch435: gdb-pie-2of6-reprelinked-ld.patch
|
||||
Patch436: gdb-pie-3of6-relocate-once.patch
|
||||
|
||||
# [expr-cumulative] using-directive: Fix memory leak (Sami Wagiaalla).
|
||||
Patch437: gdb-using-directive-leak.patch
|
||||
|
||||
BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
|
||||
Requires: readline%{?_isa}
|
||||
BuildRequires: readline-devel%{?_isa}
|
||||
|
@ -695,6 +698,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
|
|||
%patch434 -p1
|
||||
%patch435 -p1
|
||||
%patch436 -p1
|
||||
%patch437 -p1
|
||||
|
||||
%patch415 -p1
|
||||
%patch393 -p1
|
||||
|
@ -1027,6 +1031,9 @@ fi
|
|||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Mar 29 2010 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.1-3.fc13
|
||||
- [expr-cumulative] using-directive: Fix memory leak (Sami Wagiaalla).
|
||||
|
||||
* Mon Mar 29 2010 Jan Kratochvil <jan.kratochvil@redhat.com> - 7.1-2.fc13
|
||||
- Drop obsoleted `gdb-archer-pie-0315-breakpoint_address_match.patch'.
|
||||
- Do not consider memory error on reading _r_debug->r_map as fatal (BZ 576742).
|
||||
|
|
Loading…
Reference in New Issue