aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2015-02-02 07:20:58 +0400
committerJoel Brobecker <brobecker@adacore.com>2015-02-02 07:36:39 +0400
commit19a5737950b966d0ff3e50c01bb43742a870bb9e (patch)
tree3a2930ae860e98067c51ec77e062ad1aadb9520f /gdb
parentf48b30da32f7fd3d818541229d50666265f83218 (diff)
downloadfsf-binutils-gdb-19a5737950b966d0ff3e50c01bb43742a870bb9e.zip
fsf-binutils-gdb-19a5737950b966d0ff3e50c01bb43742a870bb9e.tar.gz
fsf-binutils-gdb-19a5737950b966d0ff3e50c01bb43742a870bb9e.tar.bz2
[Ada] pspace_data->sym_cache is always NULL
The Ada symbol cache has been designed to have one instance of that of that cache per program space, and for each instance to be created on-demand. ada_get_symbol_cache is the function responsible for both lookup and creation on demand. Unfortunately, ada_get_symbol_cache forgot to store the reference to newly created caches, thus causing it to: - Leak old caches; - Allocate a new cache each time the cache is being searched or a new entry is to be inserted. This patch fixes the issue by avoiding the use of the local variable, which indirectly allowed the bug to happen. We manipulate the reference in the program-space data instead. gdb/ChangeLog: PR gdb/17854: * ada-lang.c (ada_get_symbol_cache): Set pspace_data->sym_cache when allocating a new one.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/ada-lang.c9
2 files changed, 10 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e14489b..2434e2f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-02 Joel Brobecker <brobecker@adacore.com>
+
+ PR gdb/17854:
+ * ada-lang.c (ada_get_symbol_cache): Set pspace_data->sym_cache
+ when allocating a new one.
+
2015-01-31 Joel Brobecker <brobecker@adacore.com>
PR symtab/17855
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index ec06693..2dc5419 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4393,15 +4393,14 @@ static struct ada_symbol_cache *
ada_get_symbol_cache (struct program_space *pspace)
{
struct ada_pspace_data *pspace_data = get_ada_pspace_data (pspace);
- struct ada_symbol_cache *sym_cache = pspace_data->sym_cache;
- if (sym_cache == NULL)
+ if (pspace_data->sym_cache == NULL)
{
- sym_cache = XCNEW (struct ada_symbol_cache);
- ada_init_symbol_cache (sym_cache);
+ pspace_data->sym_cache = XCNEW (struct ada_symbol_cache);
+ ada_init_symbol_cache (pspace_data->sym_cache);
}
- return sym_cache;
+ return pspace_data->sym_cache;
}
/* Clear all entries from the symbol cache. */