Introduce and use compile_module_up
This introduces compile_module_up, a unique pointer for compile_module, and changes a few spots to use it. gdb/ChangeLog 2020-09-23 Tom Tromey <tom@tromey.com> * compile/compile.c (eval_compile_command): Update. * compile/compile-object-run.h (compile_object_run): Take a compile_module_up. * compile/compile-object-run.c (compile_object_run): Take a compile_module_up. * compile/compile-object-load.h (struct compile_module): Add constructor, destructor. (compile_module_up): New typedef. (compile_object_load): Return compile_object_up. * compile/compile-object-load.c (compile_object_load): Return compile_module_up.
This commit is contained in:
parent
0dbf6ee6a0
commit
e947a8482a
6 changed files with 32 additions and 12 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
2020-09-23 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* compile/compile.c (eval_compile_command): Update.
|
||||||
|
* compile/compile-object-run.h (compile_object_run): Take a
|
||||||
|
compile_module_up.
|
||||||
|
* compile/compile-object-run.c (compile_object_run): Take a
|
||||||
|
compile_module_up.
|
||||||
|
* compile/compile-object-load.h (struct compile_module): Add
|
||||||
|
constructor, destructor.
|
||||||
|
(compile_module_up): New typedef.
|
||||||
|
(compile_object_load): Return compile_object_up.
|
||||||
|
* compile/compile-object-load.c (compile_object_load): Return
|
||||||
|
compile_module_up.
|
||||||
|
|
||||||
2020-09-23 Tom Tromey <tom@tromey.com>
|
2020-09-23 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* compile/compile-object-run.c (struct do_module_cleanup): Add
|
* compile/compile-object-run.c (struct do_module_cleanup): Add
|
||||||
|
|
|
@ -582,7 +582,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
|
||||||
COMPILE_I_PRINT_ADDRESS_SCOPE when COMPILE_I_PRINT_VALUE_SCOPE
|
COMPILE_I_PRINT_ADDRESS_SCOPE when COMPILE_I_PRINT_VALUE_SCOPE
|
||||||
should have been used instead. */
|
should have been used instead. */
|
||||||
|
|
||||||
struct compile_module *
|
compile_module_up
|
||||||
compile_object_load (const compile_file_names &file_names,
|
compile_object_load (const compile_file_names &file_names,
|
||||||
enum compile_i_scope_types scope, void *scope_data)
|
enum compile_i_scope_types scope, void *scope_data)
|
||||||
{
|
{
|
||||||
|
@ -594,7 +594,6 @@ compile_object_load (const compile_file_names &file_names,
|
||||||
long storage_needed;
|
long storage_needed;
|
||||||
asymbol **symbol_table, **symp;
|
asymbol **symbol_table, **symp;
|
||||||
long number_of_symbols, missing_symbols;
|
long number_of_symbols, missing_symbols;
|
||||||
struct compile_module *retval;
|
|
||||||
struct type *regs_type, *out_value_type = NULL;
|
struct type *regs_type, *out_value_type = NULL;
|
||||||
char **matching;
|
char **matching;
|
||||||
struct objfile *objfile;
|
struct objfile *objfile;
|
||||||
|
@ -790,7 +789,7 @@ compile_object_load (const compile_file_names &file_names,
|
||||||
paddress (target_gdbarch (), out_value_addr));
|
paddress (target_gdbarch (), out_value_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = XNEW (struct compile_module);
|
compile_module_up retval (new struct compile_module);
|
||||||
retval->objfile = objfile_holder.release ();
|
retval->objfile = objfile_holder.release ();
|
||||||
retval->source_file = xstrdup (file_names.source_file ());
|
retval->source_file = xstrdup (file_names.source_file ());
|
||||||
retval->func_sym = func_sym;
|
retval->func_sym = func_sym;
|
||||||
|
|
|
@ -46,6 +46,13 @@ private:
|
||||||
|
|
||||||
struct compile_module
|
struct compile_module
|
||||||
{
|
{
|
||||||
|
compile_module () = default;
|
||||||
|
|
||||||
|
DISABLE_COPY_AND_ASSIGN (compile_module);
|
||||||
|
|
||||||
|
compile_module &operator= (compile_module &&other) = default;
|
||||||
|
compile_module (compile_module &&other) = default;
|
||||||
|
|
||||||
/* objfile for the compiled module. */
|
/* objfile for the compiled module. */
|
||||||
struct objfile *objfile;
|
struct objfile *objfile;
|
||||||
|
|
||||||
|
@ -77,7 +84,10 @@ struct compile_module
|
||||||
struct munmap_list *munmap_list_head;
|
struct munmap_list *munmap_list_head;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct compile_module *compile_object_load
|
/* A unique pointer for a compile_module. */
|
||||||
|
typedef std::unique_ptr<compile_module> compile_module_up;
|
||||||
|
|
||||||
|
extern compile_module_up compile_object_load
|
||||||
(const compile_file_names &fnames,
|
(const compile_file_names &fnames,
|
||||||
enum compile_i_scope_types scope, void *scope_data);
|
enum compile_i_scope_types scope, void *scope_data);
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ create_copied_type_recursive (objfile *objfile, type *func_type)
|
||||||
longer touch MODULE's memory after this function has been called. */
|
longer touch MODULE's memory after this function has been called. */
|
||||||
|
|
||||||
void
|
void
|
||||||
compile_object_run (struct compile_module *module)
|
compile_object_run (compile_module_up &&module)
|
||||||
{
|
{
|
||||||
struct value *func_val;
|
struct value *func_val;
|
||||||
struct do_module_cleanup *data;
|
struct do_module_cleanup *data;
|
||||||
|
@ -152,8 +152,6 @@ compile_object_run (struct compile_module *module)
|
||||||
data->munmap_list_head = module->munmap_list_head;
|
data->munmap_list_head = module->munmap_list_head;
|
||||||
|
|
||||||
xfree (module->source_file);
|
xfree (module->source_file);
|
||||||
xfree (module);
|
|
||||||
module = NULL;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
|
|
||||||
#include "compile-object-load.h"
|
#include "compile-object-load.h"
|
||||||
|
|
||||||
extern void compile_object_run (struct compile_module *module);
|
extern void compile_object_run (compile_module_up &&module);
|
||||||
|
|
||||||
#endif /* COMPILE_COMPILE_OBJECT_RUN_H */
|
#endif /* COMPILE_COMPILE_OBJECT_RUN_H */
|
||||||
|
|
|
@ -820,14 +820,13 @@ void
|
||||||
eval_compile_command (struct command_line *cmd, const char *cmd_string,
|
eval_compile_command (struct command_line *cmd, const char *cmd_string,
|
||||||
enum compile_i_scope_types scope, void *scope_data)
|
enum compile_i_scope_types scope, void *scope_data)
|
||||||
{
|
{
|
||||||
struct compile_module *compile_module;
|
|
||||||
|
|
||||||
compile_file_names fnames = compile_to_object (cmd, cmd_string, scope);
|
compile_file_names fnames = compile_to_object (cmd, cmd_string, scope);
|
||||||
|
|
||||||
gdb::unlinker object_remover (fnames.object_file ());
|
gdb::unlinker object_remover (fnames.object_file ());
|
||||||
gdb::unlinker source_remover (fnames.source_file ());
|
gdb::unlinker source_remover (fnames.source_file ());
|
||||||
|
|
||||||
compile_module = compile_object_load (fnames, scope, scope_data);
|
compile_module_up compile_module = compile_object_load (fnames, scope,
|
||||||
|
scope_data);
|
||||||
if (compile_module == NULL)
|
if (compile_module == NULL)
|
||||||
{
|
{
|
||||||
gdb_assert (scope == COMPILE_I_PRINT_ADDRESS_SCOPE);
|
gdb_assert (scope == COMPILE_I_PRINT_ADDRESS_SCOPE);
|
||||||
|
@ -840,7 +839,7 @@ eval_compile_command (struct command_line *cmd, const char *cmd_string,
|
||||||
source_remover.keep ();
|
source_remover.keep ();
|
||||||
object_remover.keep ();
|
object_remover.keep ();
|
||||||
|
|
||||||
compile_object_run (compile_module);
|
compile_object_run (std::move (compile_module));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See compile/compile-internal.h. */
|
/* See compile/compile-internal.h. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue