mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-23 01:53:38 +08:00
[gdb] Don't create registry keys in destructor
Creating a registry key using emplace calls new: ... DATA *result = new DATA (std::forward<Args> (args)...); ... which can throw a bad alloc, which will terminate gdb if called from a destructor. Fix this in a few places. Tested on aarch64-linux. Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
b3ee98cda4
commit
5a43f7f040
@ -1447,7 +1447,7 @@ ada_task_list_changed (struct inferior *inf)
|
||||
static void
|
||||
ada_tasks_invalidate_pspace_data (struct program_space *pspace)
|
||||
{
|
||||
get_ada_tasks_pspace_data (pspace)->initialized_p = 0;
|
||||
ada_tasks_pspace_data_handle.clear (pspace);
|
||||
}
|
||||
|
||||
/* Invalidate the per-inferior data. */
|
||||
@ -1455,10 +1455,7 @@ ada_tasks_invalidate_pspace_data (struct program_space *pspace)
|
||||
static void
|
||||
ada_tasks_invalidate_inferior_data (struct inferior *inf)
|
||||
{
|
||||
struct ada_tasks_inferior_data *data = get_ada_tasks_inferior_data (inf);
|
||||
|
||||
data->known_tasks_kind = ADA_TASKS_UNKNOWN;
|
||||
data->task_list_valid_p = false;
|
||||
ada_tasks_inferior_data_handle.clear (inf);
|
||||
}
|
||||
|
||||
/* The 'normal_stop' observer notification callback. */
|
||||
|
@ -560,17 +560,12 @@ objfile::~objfile ()
|
||||
|
||||
/* Check to see if the current_source_symtab belongs to this objfile,
|
||||
and if so, call clear_current_source_symtab_and_line. */
|
||||
|
||||
{
|
||||
symtab_and_line cursal
|
||||
= get_current_source_symtab_and_line (this->pspace ());
|
||||
|
||||
if (cursal.symtab && cursal.symtab->compunit ()->objfile () == this)
|
||||
clear_current_source_symtab_and_line (this->pspace ());
|
||||
}
|
||||
clear_current_source_symtab_and_line (this);
|
||||
|
||||
/* Rebuild section map next time we need it. */
|
||||
get_objfile_pspace_data (m_pspace)->section_map_dirty = 1;
|
||||
auto info = objfiles_pspace_data.get (pspace ());
|
||||
if (info != nullptr)
|
||||
info->section_map_dirty = 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1631,10 +1631,12 @@ probes_table_htab_remove_objfile_probes (void **slot, void *info)
|
||||
static void
|
||||
probes_table_remove_objfile_probes (struct objfile *objfile)
|
||||
{
|
||||
svr4_info *info = get_svr4_info (objfile->pspace ());
|
||||
if (info->probes_table != nullptr)
|
||||
htab_traverse_noresize (info->probes_table.get (),
|
||||
probes_table_htab_remove_objfile_probes, objfile);
|
||||
svr4_info *info = solib_svr4_pspace_data.get (objfile->pspace ());
|
||||
if (info == nullptr || info->probes_table == nullptr)
|
||||
return;
|
||||
|
||||
htab_traverse_noresize (info->probes_table.get (),
|
||||
probes_table_htab_remove_objfile_probes, objfile);
|
||||
}
|
||||
|
||||
/* Register a solib event probe and its associated action in the
|
||||
|
20
gdb/source.c
20
gdb/source.c
@ -300,10 +300,28 @@ set_current_source_symtab_and_line (const symtab_and_line &sal)
|
||||
void
|
||||
clear_current_source_symtab_and_line (program_space *pspace)
|
||||
{
|
||||
current_source_location *loc = get_source_location (pspace);
|
||||
current_source_location *loc = current_source_key.get (pspace);
|
||||
if (loc == nullptr)
|
||||
return;
|
||||
|
||||
loc->set (nullptr, 0);
|
||||
}
|
||||
|
||||
/* Reset any information stored about a default file and line to print, if it's
|
||||
owned by OBJFILE. */
|
||||
|
||||
void
|
||||
clear_current_source_symtab_and_line (objfile *objfile)
|
||||
{
|
||||
current_source_location *loc = current_source_key.get (objfile->pspace ());
|
||||
if (loc == nullptr)
|
||||
return;
|
||||
|
||||
if (loc->symtab () != nullptr
|
||||
&& loc->symtab ()->compunit ()->objfile () == objfile)
|
||||
clear_current_source_symtab_and_line (objfile->pspace ());
|
||||
}
|
||||
|
||||
/* See source.h. */
|
||||
|
||||
void
|
||||
|
@ -25,6 +25,7 @@
|
||||
struct program_space;
|
||||
struct symtab;
|
||||
struct symtab_and_line;
|
||||
struct objfile;
|
||||
|
||||
/* See openp function definition for their description. */
|
||||
|
||||
@ -132,6 +133,7 @@ extern symtab_and_line set_current_source_symtab_and_line
|
||||
|
||||
/* Reset any information stored about a default file and line to print. */
|
||||
extern void clear_current_source_symtab_and_line (program_space *pspace);
|
||||
extern void clear_current_source_symtab_and_line (objfile *objfile);
|
||||
|
||||
/* Add a source path substitution rule. */
|
||||
extern void add_substitute_path_rule (const char *, const char *);
|
||||
|
@ -1756,7 +1756,7 @@ symtab_all_objfiles_removed (program_space *pspace)
|
||||
symbol_cache_flush (pspace);
|
||||
|
||||
/* Forget everything we know about the main function. */
|
||||
set_main_name (pspace, nullptr, language_unknown);
|
||||
main_progspace_key.clear (pspace);
|
||||
}
|
||||
|
||||
/* This module's 'free_objfile' observer. */
|
||||
|
Loading…
Reference in New Issue
Block a user