Use ui_file_as_string in gdb/compile/

Using ui_file_as_string would imply changing a few prototypes to pass
around source and object file names as std::string.  Instead of that,
wrap those two in a new class.  This ends up eliminating a small
wrinkle: get_new_file_names and compile_object_load have swapped
parameters.  The former takes "source, objfile", while the latter
takes "objfile, source".

gdb/ChangeLog:
2016-11-08  Pedro Alves  <palves@redhat.com>

	* c-lang.h (c_compute_program): Now returns std::string.
	* compile/compile-internal.h (class compile_file_names): New
	class.
	* compile/compile-object-load.c (compile_object_load): Replace
	object_file and source_file parameters with a compile_file_names
	parameter.  Adjust.
	* compile-object-load.h: Include "compile-internal.h".
	(compile_object_load): Replace object_file and source_file
	parameters with a compile_file_names parameter.
	* compile/compile-c-support.c (c_compute_program): Now returns a
	std::string.  Use ui_file_as_string.
	* compile/compile.c (get_new_file_names): Remove parameters and
	return a compile_file_names instead.
	(compile_to_object): Now returns a compile_file_names.  Use
	ui_file_as_string.
	(eval_compile_command): Use compile_file_names.
	* language.h (struct language_defn) <la_compute_program>: Now
	returns std::string.
This commit is contained in:
Pedro Alves 2016-11-08 15:26:46 +00:00
parent 3d8b0d9483
commit aaee65aea2
8 changed files with 122 additions and 86 deletions

View file

@ -601,16 +601,14 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
}
}
/* Load OBJECT_FILE into inferior memory. Throw an error otherwise.
Caller must fully dispose the return value by calling compile_object_run.
SOURCE_FILE's copy is stored into the returned object.
Caller should free both OBJECT_FILE and SOURCE_FILE immediatelly after this
function returns.
Function returns NULL only for COMPILE_I_PRINT_ADDRESS_SCOPE when
COMPILE_I_PRINT_VALUE_SCOPE should have been used instead. */
/* Load the object file specified in FILE_NAMES into inferior memory.
Throw an error otherwise. Caller must fully dispose the return
value by calling compile_object_run. Returns NULL only for
COMPILE_I_PRINT_ADDRESS_SCOPE when COMPILE_I_PRINT_VALUE_SCOPE
should have been used instead. */
struct compile_module *
compile_object_load (const char *object_file, const char *source_file,
compile_object_load (const compile_file_names &file_names,
enum compile_i_scope_types scope, void *scope_data)
{
struct cleanup *cleanups, *cleanups_free_objfile;
@ -633,7 +631,7 @@ compile_object_load (const char *object_file, const char *source_file,
struct type *expect_return_type;
struct munmap_list *munmap_list_head = NULL;
filename = tilde_expand (object_file);
filename = tilde_expand (file_names.object_file ());
cleanups = make_cleanup (xfree, filename);
abfd = gdb_bfd_open (filename, gnutarget, -1);
@ -824,7 +822,7 @@ compile_object_load (const char *object_file, const char *source_file,
retval = XNEW (struct compile_module);
retval->objfile = objfile;
retval->source_file = xstrdup (source_file);
retval->source_file = xstrdup (file_names.source_file ());
retval->func_sym = func_sym;
retval->regs_addr = regs_addr;
retval->scope = scope;