PR rust/21484 notes that watch -location does not work with Rust:
(gdb) watch -location a
syntax error in expression, near `) 0x00007fffffffe0f4'.
update_watchpoint tries to tell gdb that the new expression it creates
has C syntax:
/* The above expression is in C. */
b->language = language_c;
However, update_watchpoint doesn't actually use this language when
re-parsing the expression.
Originally I was going to fix this by saving and restoring the
language in update_watchpoint, but this regressed
gdb.dlang/watch-loc.exp, because the constructed expression actually
has D syntax (specifically the name is not parseable by C).
Next I looked at directly constructing an expression, and not relying
on the parser at all; but it seemed to me that upon a re-set, we'd
want to reparse the type, and there is no existing API to do this
correctly.
So, in the end I made a hook to let each language choose what
expression to use. I made all the languages other than Rust use the C
expression, because that is the status quo ante. However, this is
probably not truly correct. After this patch, at least, it is easy to
correct by someone who knows the language(s) in question.
Regtested by the buildbot.
ChangeLog
2017-05-19 Tom Tromey <tom@tromey.com>
PR rust/21484:
* rust-lang.c (exp_descriptor_rust): New function.
(rust_language_defn): Use it.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn)
<la_watch_location_expression>: New member.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Update.
* go-lang.c (go_language_defn): Update.
* f-lang.c (f_language_defn): Update.
* d-lang.c (d_language_defn): Update.
* c-lang.h (c_watch_location_expression): Declare.
* c-lang.c (c_watch_location_expression): New function.
(c_language_defn, cplus_language_defn, asm_language_defn)
(minimal_language_defn): Use it.
* breakpoint.c (watch_command_1): Call
la_watch_location_expression.
* ada-lang.c (ada_language_defn): Update.
testsuite/ChangeLog
2017-05-19 Tom Tromey <tom@tromey.com>
PR rust/21484:
* gdb.rust/watch.exp: New file.
* gdb.rust/watch.rs: New file.
-Wwrite-strings flags several cases of missing casts around
initializations like:
static char *gdb_completer_command_word_break_characters =
" \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,";
Obviously these could/should be const. However, while at it, there's
no need for these variables to be pointers instead of arrays. They
are never changed to point to anything else.
Unfortunately, readline's rl_completer_word_break_characters is
"char *", not "const char *". So we always need a cast somewhere. The
approach taken here is to add a new
set_rl_completer_word_break_characters function that becomes the only
place that writes to rl_completer_word_break_characters, and thus the
single place that needs the cast.
gdb/ChangeLog:
2017-04-05 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_completer_word_break_characters): Now a const
array.
(ada_get_gdb_completer_word_break_characters): Constify.
* completer.c (gdb_completer_command_word_break_characters)
(gdb_completer_file_name_break_characters)
(gdb_completer_quote_characters): Now const arrays.
(get_gdb_completer_quote_characters): Constify.
(set_rl_completer_word_break_characters): New function.
(set_gdb_completion_word_break_characters)
(complete_line_internal): Use it.
* completer.h (get_gdb_completer_quote_characters): Constify.
(set_rl_completer_word_break_characters): Declare.
* f-lang.c (f_word_break_characters): Constify.
* language.c (default_word_break_characters): Constify.
* language.h (language_defn::la_word_break_characters): Constify.
(default_word_break_characters): Constify.
* top.c (init_main): Use set_rl_completer_word_break_characters.
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.
gdb/ChangeLog:
Update copyright year range in all GDB files.
This patch moves most of the demangling logic out of
symbol_find_demangled_name into the various language_defn objects.
The simplest way to do this seemed to be to add a new method to
language_defn. This is shame given the existing la_demangle, but
given Ada's unusual needs, and the differing demangling options
between languages, la_demangle didn't seem to fit.
In order to make this work, I made enum language order-sensitive.
This helps preserve the current ordering of demangling operations.
2016-06-23 Tom Tromey <tom@tromey.com>
* symtab.c (symbol_find_demangled_name): Loop over languages and
use language_sniff_from_mangled_name.
* rust-lang.c (rust_sniff_from_mangled_name): New function.
(rust_language_defn): Update.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_sniff_from_mangled_name): New function.
(objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_sniff_from_mangled_name>: New
field.
(language_sniff_from_mangled_name): Declare.
* language.c (language_sniff_from_mangled_name): New function.
(unknown_language_defn, auto_language_defn, local_language_defn):
Update.
* jv-lang.c (java_sniff_from_mangled_name): New function.
(java_language_defn): Use it.
* go-lang.c (go_sniff_from_mangled_name): New function.
(go_language_defn): Use it.
* f-lang.c (f_language_defn): Update.
* defs.h (enum language): Reorder.
* d-lang.c (d_sniff_from_mangled_name): New function.
(d_language_defn): Use it.
* cp-support.h (gdb_sniff_from_mangled_name): Declare.
* cp-support.c (gdb_sniff_from_mangled_name): New function.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-lang.c (ada_sniff_from_mangled_name): New function.
(ada_language_defn): Use it.
This moves filename extensions from a function in symfile.c out to
each language_defn. I think this is an improvement because it means
less digging around when writing a new language port.
2016-06-23 Tom Tromey <tom@tromey.com>
* ada-lang.c (ada_extensions): New array.
(ada_language_defn): Use it.
* c-lang.c (c_extensions): New array.
(c_language_defn): Use it.
(cplus_extensions): New array.
(cplus_language_defn): Use it.
(asm_extensions): New array.
(asm_language_defn): Use it.
(minimal_language_defn): Update.
* d-lang.c (d_extensions): New array.
(d_language_defn): Use it.
* f-lang.c (f_extensions): New array.
(f_language_defn): Use it.
* go-lang.c (go_language_defn): Update.
* jv-lang.c (java_extensions): New array.
(java_language_defn): Use it.
* language.c (add_language): Call add_filename_language.
(unknown_language_defn, auto_language_defn, local_language_defn):
Update.
* language.h (struct language_defn) <la_filename_extensions>: New
field.
* m2-lang.c (m2_language_defn): Update.
* objc-lang.c (objc_extensions): New array.
(objc_language_defn): Use it.
* opencl-lang.c (opencl_language_defn): Update.
* p-lang.c (p_extensions): New array.
(pascal_language_defn): Use it.
* rust-lang.c (rust_extensions): New array.
(rust_language_defn): Use it.
* symfile.c (add_filename_language): No longer static. Make "ext"
const.
(init_filename_language_table): Remove.
(_initialize_symfile): Update.
* symfile.h (add_filename_language): Declare.
The get_frame_language feels like it would be more at home in frame.c
rather than in stack.c, while the declaration, that is currently in
language.h can be moved into frame.h to match.
A couple of new includes are added, but otherwise no substantial change
here.
gdb/ChangeLog:
* stack.c (get_frame_language): Moved ...
* frame.c (get_frame_language): ... to here.
* language.h (get_frame_language): Declaration moved to frame.h.
* frame.h: Add language.h include, for language enum.
(get_frame_language): Declaration moved from language.h.
* language.c: Add frame.h include.
* top.c: Add frame.h include.
* symtab.h (struct obj_section): Declare.
(struct cmd_list_element): Declare.
As part of a drive to remove deprecated_safe_get_selected_frame, make
the get_frame_language function take a frame parameter. Given the name
of the function this actually seems to make a lot of sense.
The task of fetching a suitable frame is then passed to the calling
functions. For get_frame_language there are not many callers, these are
updated to get the selected frame in a suitable way.
gdb/ChangeLog:
* language.c (show_language_command): Find selected frame before
asking for the language of that frame.
(set_language_command): Likewise.
* language.h (get_frame_language): Add frame parameter.
* stack.c (get_frame_language): Add frame parameter, assert
parameter is not NULL, update comment and reindent.
* top.c (check_frame_language_change): Pass the selected frame
into get_frame_language.
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
gdb/ChangeLog:
* ada-lang.c (user_select_syms): Only fetch symtab if symbol is
objfile-owned.
(cache_symbol): Ignore symbols that are not objfile-owned.
* block.c (block_objfile): New function.
(block_gdbarch): New function.
* block.h (block_objfile): Declare.
(block_gdbarch): Declare.
* c-exp.y (classify_name): Remove call to
language_lookup_primitive_type. No longer necessary.
* gdbtypes.c (lookup_typename): Call lookup_symbol_in_language.
Remove call to language_lookup_primitive_type. No longer necessary.
* guile/scm-symbol.c (syscm_gdbarch_data_key): New static global.
(syscm_gdbarch_data): New struct.
(syscm_init_arch_symbols): New function.
(syscm_get_symbol_map): Renamed from syscm_objfile_symbol_map.
All callers updated. Handle symbols owned by arches.
(gdbscm_symbol_symtab): Handle symbols owned by arches.
(gdbscm_initialize_symbols): Initialize syscm_gdbarch_data_key.
* language.c (language_lookup_primitive_type_1): New function.
(language_lookup_primitive_type): Call it.
(language_alloc_type_symbol): New function.
(language_init_primitive_type_symbols): New function.
(language_lookup_primitive_type_as_symbol): New function.
* language.h (struct language_arch_info) <primitive_type_symbols>:
New member.
(language_lookup_primitive_type): Add function comment.
(language_lookup_primitive_type_as_symbol): Declare.
* printcmd.c (address_info): Handle arch-owned symbols.
* python/py-symbol.c (sympy_get_symtab): Ditto.
(set_symbol): Ditto.
(sympy_dealloc): Ditto.
* symmisc.c (print_symbol): Ditto.
* symtab.c (fixup_symbol_section): Ditto.
(lookup_symbol_aux): Initialize block_found.
(basic_lookup_symbol_nonlocal): Try looking up the symbol as a
primitive type.
(initialize_objfile_symbol_1): New function.
(initialize_objfile_symbol): Call it.
(allocate_symbol): Call it.
(allocate_template_symbol): Call it.
(symbol_objfile): Assert symbol is objfile-owned.
(symbol_arch, symbol_symtab, symbol_set_symtab): Ditto.
* symtab.h (struct symbol) <owner>: Replaces member "symtab".
(struct symbol) <is_objfile_owned>: New member.
(SYMBOL_OBJFILE_OWNED): New macro.
* cp-namespace.c (cp_lookup_bare_symbol): New arg langdef.
All callers updated. Try to find the symbol as a primitive type.
(lookup_namespace_scope): New arg langdef. All callers updated.
Call cp_lookup_bare_symbol directly for simple bare symbols.
This final patch adds the new "compile" command and subcommands, and
all the machinery needed to make it work.
A shared library supplied by gcc is used for all communications with
gcc. Types and most aspects of symbols are provided directly by gdb
to the compiler using this library.
gdb provides some information about the user's code using plain text.
Macros are emitted this way, and DWARF location expressions (and
bounds for VLA) are compiled to C code.
This hybrid approach was taken because, on the one hand, it is better
to provide global declarations and such on demand; but on the other
hand, for local variables, translating DWARF location expressions to C
was much simpler than exporting a full compiler API to gdb -- the same
result, only easier to implement, understand, and debug.
In the ordinary mode, the user's expression is wrapped in a dummy
function. After compilation, gdb inserts the resulting object code
into the inferior, then calls this function.
Access to local variables is provided by noting which registers are
used by location expressions, and passing a structure of register
values into the function. Writes to registers are supported by
copying out these values after the function returns.
This approach was taken so that we could eventually implement other
more interesting features based on this same infrastructure; for
example, we're planning to investigate inferior-side breakpoint
conditions.
gdb/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
Tom Tromey <tromey@redhat.com>
* NEWS: Update.
* symtab.h (struct symbol_computed_ops) <generate_c_location>: New
field.
* p-lang.c (pascal_language_defn): Update.
* opencl-lang.c (opencl_language_defn): Update.
* objc-lang.c (objc_language_defn): Update.
* m2-lang.c (m2_language_defn): Update.
* language.h (struct language_defn) <la_get_compile_instance,
la_compute_program>: New fields.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Update.
* jv-lang.c (java_language_defn): Update.
* go-lang.c (go_language_defn): Update.
* f-lang.c (f_language_defn): Update.
* dwarf2loc.h (dwarf2_compile_property_to_c): Declare.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): New
functions.
(dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update.
* defs.h (enum compile_i_scope_types): New.
(enum command_control_type) <compile_control>: New constant.
(struct command_line) <control_u>: New field.
* d-lang.c (d_language_defn): Update.
* compile/compile.c: New file.
* compile/compile-c-support.c: New file.
* compile/compile-c-symbols.c: New file.
* compile/compile-c-types.c: New file.
* compile/compile.h: New file.
* compile/compile-internal.h: New file.
* compile/compile-loc2c.c: New file.
* compile/compile-object-load.c: New file.
* compile/compile-object-load.h: New file.
* compile/compile-object-run.c: New file.
* compile/compile-object-run.h: New file.
* cli/cli-script.c (multi_line_command_p, print_command_lines)
(execute_control_command, process_next_line)
(recurse_read_control_structure): Handle compile_control.
* c-lang.h (c_get_compile_context, c_compute_program): Declare.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Update.
* ada-lang.c (ada_language_defn): Update.
* Makefile.in (SUBDIR_GCC_COMPILE_OBS, SUBDIR_GCC_COMPILE_SRCS):
New variables.
(SFILES): Add SUBDIR_GCC_COMPILE_SRCS.
(HFILES_NO_SRCDIR): Add compile.h.
(COMMON_OBS): Add SUBDIR_GCC_COMPILE_OBS.
(INIT_FILES): Add SUBDIR_GCC_COMPILE_SRCS.
(compile.o, compile-c-types.o, compile-c-symbols.o)
(compile-object-load.o, compile-object-run.o, compile-loc2c.o)
(compile-c-support.o): New targets.
gdb/doc/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.texinfo (Altering): Update.
(Compiling and Injecting Code): New node.
gdb/testsuite/ChangeLog
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
Tom Tromey <tromey@redhat.com>
* configure.ac: Add gdb.compile/.
* configure: Regenerate.
* gdb.compile/Makefile.in: New file.
* gdb.compile/compile-ops.exp: New file.
* gdb.compile/compile-ops.c: New file.
* gdb.compile/compile-tls.c: New file.
* gdb.compile/compile-tls.exp: New file.
* gdb.compile/compile-constvar.S: New file.
* gdb.compile/compile-constvar.c: New file.
* gdb.compile/compile-mod.c: New file.
* gdb.compile/compile-nodebug.c: New file.
* gdb.compile/compile-setjmp-mod.c: New file.
* gdb.compile/compile-setjmp.c: New file.
* gdb.compile/compile-setjmp.exp: New file.
* gdb.compile/compile-shlib.c: New file.
* gdb.compile/compile.c: New file.
* gdb.compile/compile.exp: New file.
* lib/gdb.exp (skip_compile_feature_tests): New proc.
Currently there are many calls to help_list that pass the constant -1
as the "class" value. However, the parameter is declared as being of
type enum command_class, and uses of the constant violate this
abstraction.
This patch fixes the error everywhere it occurs in the gdb sources.
Tested by rebuilding.
2014-06-13 Tom Tromey <tromey@redhat.com>
* cp-support.c (maint_cplus_command): Pass all_commands, not -1,
to help_list.
* guile/guile.c (info_guile_command): Pass all_commands, not -1,
to help_list.
* tui/tui-win.c (tui_command): Pass all_commands, not -1, to
help_list.
* tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to
help_list.Pass all_commands, not -1, to help_list.
* cli/cli-dump.c (dump_command, append_command)
(srec_dump_command, ihex_dump_command, tekhex_dump_command)
(binary_dump_command, binary_append_command): Pass all_commands,
not -1, to help_list.
* cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not
-1, to help_list.
* valprint.c (set_print, set_print_raw): Pass all_commands, not
-1, to help_list.
* typeprint.c (set_print_type): Pass all_commands, not -1, to
help_list.
* top.c (set_history): Pass all_commands, not -1, to help_list.
* target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass
all_commands, not -1, to help_list.
* symfile.c (overlay_command): Pass all_commands, not -1, to
help_list.
* spu-tdep.c (info_spu_command): Pass all_commands, not -1, to
help_list.
* serial.c (serial_set_cmd): Pass all_commands, not -1, to
help_list.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not
-1, to help_list.
* remote.c (remote_command, set_remote_cmd): Pass all_commands,
not -1, to help_list.
* ravenscar-thread.c (set_ravenscar_command): Pass all_commands,
not -1, to help_list.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_print_command, maintenance_set_cmd): Pass
all_commands, not -1, to help_list.
* macrocmd.c (macro_command): Pass all_commands, not -1, to
help_list.
* language.c (set_check): Pass all_commands, not -1, to help_list.
* infcmd.c (unset_command): Pass all_commands, not -1, to
help_list.
* frame.c (set_backtrace_cmd): Pass all_commands, not -1, to
help_list.
* dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to
help_list.
* dcache.c (set_dcache_command): Pass all_commands, not -1, to
help_list.
* breakpoint.c (save_command): Pass all_commands, not -1, to
help_list.
* ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass
all_commands, not -1, to help_list.
This removes gdb_string.h. This patch is purely mechanical. I
created it by running the two commands:
git rm common/gdb_string.h
perl -pi -e's/"gdb_string.h"/<string.h>/;' *.[chyl] */*.[chyl]
2013-11-18 Tom Tromey <tromey@redhat.com>
* common/gdb_string.h: Remove.
* aarch64-tdep.c: Use string.h, not gdb_string.h.
* ada-exp.y: Use string.h, not gdb_string.h.
* ada-lang.c: Use string.h, not gdb_string.h.
* ada-lex.l: Use string.h, not gdb_string.h.
* ada-typeprint.c: Use string.h, not gdb_string.h.
* ada-valprint.c: Use string.h, not gdb_string.h.
* aix-thread.c: Use string.h, not gdb_string.h.
* alpha-linux-tdep.c: Use string.h, not gdb_string.h.
* alpha-mdebug-tdep.c: Use string.h, not gdb_string.h.
* alpha-nat.c: Use string.h, not gdb_string.h.
* alpha-osf1-tdep.c: Use string.h, not gdb_string.h.
* alpha-tdep.c: Use string.h, not gdb_string.h.
* alphanbsd-tdep.c: Use string.h, not gdb_string.h.
* amd64-dicos-tdep.c: Use string.h, not gdb_string.h.
* amd64-linux-nat.c: Use string.h, not gdb_string.h.
* amd64-linux-tdep.c: Use string.h, not gdb_string.h.
* amd64-nat.c: Use string.h, not gdb_string.h.
* amd64-sol2-tdep.c: Use string.h, not gdb_string.h.
* amd64fbsd-tdep.c: Use string.h, not gdb_string.h.
* amd64obsd-tdep.c: Use string.h, not gdb_string.h.
* arch-utils.c: Use string.h, not gdb_string.h.
* arm-linux-nat.c: Use string.h, not gdb_string.h.
* arm-linux-tdep.c: Use string.h, not gdb_string.h.
* arm-tdep.c: Use string.h, not gdb_string.h.
* arm-wince-tdep.c: Use string.h, not gdb_string.h.
* armbsd-tdep.c: Use string.h, not gdb_string.h.
* armnbsd-nat.c: Use string.h, not gdb_string.h.
* armnbsd-tdep.c: Use string.h, not gdb_string.h.
* armobsd-tdep.c: Use string.h, not gdb_string.h.
* avr-tdep.c: Use string.h, not gdb_string.h.
* ax-gdb.c: Use string.h, not gdb_string.h.
* ax-general.c: Use string.h, not gdb_string.h.
* bcache.c: Use string.h, not gdb_string.h.
* bfin-tdep.c: Use string.h, not gdb_string.h.
* breakpoint.c: Use string.h, not gdb_string.h.
* build-id.c: Use string.h, not gdb_string.h.
* buildsym.c: Use string.h, not gdb_string.h.
* c-exp.y: Use string.h, not gdb_string.h.
* c-lang.c: Use string.h, not gdb_string.h.
* c-typeprint.c: Use string.h, not gdb_string.h.
* c-valprint.c: Use string.h, not gdb_string.h.
* charset.c: Use string.h, not gdb_string.h.
* cli-out.c: Use string.h, not gdb_string.h.
* cli/cli-cmds.c: Use string.h, not gdb_string.h.
* cli/cli-decode.c: Use string.h, not gdb_string.h.
* cli/cli-dump.c: Use string.h, not gdb_string.h.
* cli/cli-interp.c: Use string.h, not gdb_string.h.
* cli/cli-logging.c: Use string.h, not gdb_string.h.
* cli/cli-script.c: Use string.h, not gdb_string.h.
* cli/cli-setshow.c: Use string.h, not gdb_string.h.
* cli/cli-utils.c: Use string.h, not gdb_string.h.
* coffread.c: Use string.h, not gdb_string.h.
* common/common-utils.c: Use string.h, not gdb_string.h.
* common/filestuff.c: Use string.h, not gdb_string.h.
* common/linux-procfs.c: Use string.h, not gdb_string.h.
* common/linux-ptrace.c: Use string.h, not gdb_string.h.
* common/signals.c: Use string.h, not gdb_string.h.
* common/vec.h: Use string.h, not gdb_string.h.
* core-regset.c: Use string.h, not gdb_string.h.
* corefile.c: Use string.h, not gdb_string.h.
* corelow.c: Use string.h, not gdb_string.h.
* cp-abi.c: Use string.h, not gdb_string.h.
* cp-support.c: Use string.h, not gdb_string.h.
* cp-valprint.c: Use string.h, not gdb_string.h.
* cris-tdep.c: Use string.h, not gdb_string.h.
* d-lang.c: Use string.h, not gdb_string.h.
* dbxread.c: Use string.h, not gdb_string.h.
* dcache.c: Use string.h, not gdb_string.h.
* demangle.c: Use string.h, not gdb_string.h.
* dicos-tdep.c: Use string.h, not gdb_string.h.
* disasm.c: Use string.h, not gdb_string.h.
* doublest.c: Use string.h, not gdb_string.h.
* dsrec.c: Use string.h, not gdb_string.h.
* dummy-frame.c: Use string.h, not gdb_string.h.
* dwarf2-frame.c: Use string.h, not gdb_string.h.
* dwarf2loc.c: Use string.h, not gdb_string.h.
* dwarf2read.c: Use string.h, not gdb_string.h.
* elfread.c: Use string.h, not gdb_string.h.
* environ.c: Use string.h, not gdb_string.h.
* eval.c: Use string.h, not gdb_string.h.
* event-loop.c: Use string.h, not gdb_string.h.
* exceptions.c: Use string.h, not gdb_string.h.
* exec.c: Use string.h, not gdb_string.h.
* expprint.c: Use string.h, not gdb_string.h.
* f-exp.y: Use string.h, not gdb_string.h.
* f-lang.c: Use string.h, not gdb_string.h.
* f-typeprint.c: Use string.h, not gdb_string.h.
* f-valprint.c: Use string.h, not gdb_string.h.
* fbsd-nat.c: Use string.h, not gdb_string.h.
* findcmd.c: Use string.h, not gdb_string.h.
* findvar.c: Use string.h, not gdb_string.h.
* fork-child.c: Use string.h, not gdb_string.h.
* frame.c: Use string.h, not gdb_string.h.
* frv-linux-tdep.c: Use string.h, not gdb_string.h.
* frv-tdep.c: Use string.h, not gdb_string.h.
* gdb.c: Use string.h, not gdb_string.h.
* gdb_bfd.c: Use string.h, not gdb_string.h.
* gdbarch.c: Use string.h, not gdb_string.h.
* gdbtypes.c: Use string.h, not gdb_string.h.
* gnu-nat.c: Use string.h, not gdb_string.h.
* gnu-v2-abi.c: Use string.h, not gdb_string.h.
* gnu-v3-abi.c: Use string.h, not gdb_string.h.
* go-exp.y: Use string.h, not gdb_string.h.
* go-lang.c: Use string.h, not gdb_string.h.
* go32-nat.c: Use string.h, not gdb_string.h.
* hppa-hpux-tdep.c: Use string.h, not gdb_string.h.
* hppa-linux-nat.c: Use string.h, not gdb_string.h.
* hppanbsd-tdep.c: Use string.h, not gdb_string.h.
* hppaobsd-tdep.c: Use string.h, not gdb_string.h.
* i386-cygwin-tdep.c: Use string.h, not gdb_string.h.
* i386-dicos-tdep.c: Use string.h, not gdb_string.h.
* i386-linux-nat.c: Use string.h, not gdb_string.h.
* i386-linux-tdep.c: Use string.h, not gdb_string.h.
* i386-nto-tdep.c: Use string.h, not gdb_string.h.
* i386-sol2-tdep.c: Use string.h, not gdb_string.h.
* i386-tdep.c: Use string.h, not gdb_string.h.
* i386bsd-tdep.c: Use string.h, not gdb_string.h.
* i386gnu-nat.c: Use string.h, not gdb_string.h.
* i386nbsd-tdep.c: Use string.h, not gdb_string.h.
* i386obsd-tdep.c: Use string.h, not gdb_string.h.
* i387-tdep.c: Use string.h, not gdb_string.h.
* ia64-libunwind-tdep.c: Use string.h, not gdb_string.h.
* ia64-linux-nat.c: Use string.h, not gdb_string.h.
* inf-child.c: Use string.h, not gdb_string.h.
* inf-ptrace.c: Use string.h, not gdb_string.h.
* inf-ttrace.c: Use string.h, not gdb_string.h.
* infcall.c: Use string.h, not gdb_string.h.
* infcmd.c: Use string.h, not gdb_string.h.
* inflow.c: Use string.h, not gdb_string.h.
* infrun.c: Use string.h, not gdb_string.h.
* interps.c: Use string.h, not gdb_string.h.
* iq2000-tdep.c: Use string.h, not gdb_string.h.
* irix5-nat.c: Use string.h, not gdb_string.h.
* jv-exp.y: Use string.h, not gdb_string.h.
* jv-lang.c: Use string.h, not gdb_string.h.
* jv-typeprint.c: Use string.h, not gdb_string.h.
* jv-valprint.c: Use string.h, not gdb_string.h.
* language.c: Use string.h, not gdb_string.h.
* linux-fork.c: Use string.h, not gdb_string.h.
* linux-nat.c: Use string.h, not gdb_string.h.
* lm32-tdep.c: Use string.h, not gdb_string.h.
* m2-exp.y: Use string.h, not gdb_string.h.
* m2-typeprint.c: Use string.h, not gdb_string.h.
* m32c-tdep.c: Use string.h, not gdb_string.h.
* m32r-linux-nat.c: Use string.h, not gdb_string.h.
* m32r-linux-tdep.c: Use string.h, not gdb_string.h.
* m32r-rom.c: Use string.h, not gdb_string.h.
* m32r-tdep.c: Use string.h, not gdb_string.h.
* m68hc11-tdep.c: Use string.h, not gdb_string.h.
* m68k-tdep.c: Use string.h, not gdb_string.h.
* m68kbsd-tdep.c: Use string.h, not gdb_string.h.
* m68klinux-nat.c: Use string.h, not gdb_string.h.
* m68klinux-tdep.c: Use string.h, not gdb_string.h.
* m88k-tdep.c: Use string.h, not gdb_string.h.
* macrocmd.c: Use string.h, not gdb_string.h.
* main.c: Use string.h, not gdb_string.h.
* mdebugread.c: Use string.h, not gdb_string.h.
* mem-break.c: Use string.h, not gdb_string.h.
* memattr.c: Use string.h, not gdb_string.h.
* memory-map.c: Use string.h, not gdb_string.h.
* mep-tdep.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-break.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-disas.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-env.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-stack.c: Use string.h, not gdb_string.h.
* mi/mi-cmd-var.c: Use string.h, not gdb_string.h.
* mi/mi-cmds.c: Use string.h, not gdb_string.h.
* mi/mi-console.c: Use string.h, not gdb_string.h.
* mi/mi-getopt.c: Use string.h, not gdb_string.h.
* mi/mi-interp.c: Use string.h, not gdb_string.h.
* mi/mi-main.c: Use string.h, not gdb_string.h.
* mi/mi-parse.c: Use string.h, not gdb_string.h.
* microblaze-rom.c: Use string.h, not gdb_string.h.
* microblaze-tdep.c: Use string.h, not gdb_string.h.
* mingw-hdep.c: Use string.h, not gdb_string.h.
* minidebug.c: Use string.h, not gdb_string.h.
* minsyms.c: Use string.h, not gdb_string.h.
* mips-irix-tdep.c: Use string.h, not gdb_string.h.
* mips-linux-tdep.c: Use string.h, not gdb_string.h.
* mips-tdep.c: Use string.h, not gdb_string.h.
* mips64obsd-tdep.c: Use string.h, not gdb_string.h.
* mipsnbsd-tdep.c: Use string.h, not gdb_string.h.
* mipsread.c: Use string.h, not gdb_string.h.
* mn10300-linux-tdep.c: Use string.h, not gdb_string.h.
* mn10300-tdep.c: Use string.h, not gdb_string.h.
* monitor.c: Use string.h, not gdb_string.h.
* moxie-tdep.c: Use string.h, not gdb_string.h.
* mt-tdep.c: Use string.h, not gdb_string.h.
* nbsd-tdep.c: Use string.h, not gdb_string.h.
* nios2-linux-tdep.c: Use string.h, not gdb_string.h.
* nto-procfs.c: Use string.h, not gdb_string.h.
* nto-tdep.c: Use string.h, not gdb_string.h.
* objc-lang.c: Use string.h, not gdb_string.h.
* objfiles.c: Use string.h, not gdb_string.h.
* opencl-lang.c: Use string.h, not gdb_string.h.
* osabi.c: Use string.h, not gdb_string.h.
* osdata.c: Use string.h, not gdb_string.h.
* p-exp.y: Use string.h, not gdb_string.h.
* p-lang.c: Use string.h, not gdb_string.h.
* p-typeprint.c: Use string.h, not gdb_string.h.
* parse.c: Use string.h, not gdb_string.h.
* posix-hdep.c: Use string.h, not gdb_string.h.
* ppc-linux-nat.c: Use string.h, not gdb_string.h.
* ppc-sysv-tdep.c: Use string.h, not gdb_string.h.
* ppcfbsd-tdep.c: Use string.h, not gdb_string.h.
* ppcnbsd-tdep.c: Use string.h, not gdb_string.h.
* ppcobsd-tdep.c: Use string.h, not gdb_string.h.
* printcmd.c: Use string.h, not gdb_string.h.
* procfs.c: Use string.h, not gdb_string.h.
* prologue-value.c: Use string.h, not gdb_string.h.
* python/py-auto-load.c: Use string.h, not gdb_string.h.
* python/py-gdb-readline.c: Use string.h, not gdb_string.h.
* ravenscar-thread.c: Use string.h, not gdb_string.h.
* regcache.c: Use string.h, not gdb_string.h.
* registry.c: Use string.h, not gdb_string.h.
* remote-fileio.c: Use string.h, not gdb_string.h.
* remote-m32r-sdi.c: Use string.h, not gdb_string.h.
* remote-mips.c: Use string.h, not gdb_string.h.
* remote-sim.c: Use string.h, not gdb_string.h.
* remote.c: Use string.h, not gdb_string.h.
* reverse.c: Use string.h, not gdb_string.h.
* rs6000-aix-tdep.c: Use string.h, not gdb_string.h.
* ser-base.c: Use string.h, not gdb_string.h.
* ser-go32.c: Use string.h, not gdb_string.h.
* ser-mingw.c: Use string.h, not gdb_string.h.
* ser-pipe.c: Use string.h, not gdb_string.h.
* ser-tcp.c: Use string.h, not gdb_string.h.
* ser-unix.c: Use string.h, not gdb_string.h.
* serial.c: Use string.h, not gdb_string.h.
* sh-tdep.c: Use string.h, not gdb_string.h.
* sh64-tdep.c: Use string.h, not gdb_string.h.
* shnbsd-tdep.c: Use string.h, not gdb_string.h.
* skip.c: Use string.h, not gdb_string.h.
* sol-thread.c: Use string.h, not gdb_string.h.
* solib-dsbt.c: Use string.h, not gdb_string.h.
* solib-frv.c: Use string.h, not gdb_string.h.
* solib-osf.c: Use string.h, not gdb_string.h.
* solib-spu.c: Use string.h, not gdb_string.h.
* solib-target.c: Use string.h, not gdb_string.h.
* solib.c: Use string.h, not gdb_string.h.
* somread.c: Use string.h, not gdb_string.h.
* source.c: Use string.h, not gdb_string.h.
* sparc-nat.c: Use string.h, not gdb_string.h.
* sparc-sol2-tdep.c: Use string.h, not gdb_string.h.
* sparc-tdep.c: Use string.h, not gdb_string.h.
* sparc64-tdep.c: Use string.h, not gdb_string.h.
* sparc64fbsd-tdep.c: Use string.h, not gdb_string.h.
* sparc64nbsd-tdep.c: Use string.h, not gdb_string.h.
* sparcnbsd-tdep.c: Use string.h, not gdb_string.h.
* spu-linux-nat.c: Use string.h, not gdb_string.h.
* spu-multiarch.c: Use string.h, not gdb_string.h.
* spu-tdep.c: Use string.h, not gdb_string.h.
* stabsread.c: Use string.h, not gdb_string.h.
* stack.c: Use string.h, not gdb_string.h.
* std-regs.c: Use string.h, not gdb_string.h.
* symfile.c: Use string.h, not gdb_string.h.
* symmisc.c: Use string.h, not gdb_string.h.
* symtab.c: Use string.h, not gdb_string.h.
* target.c: Use string.h, not gdb_string.h.
* thread.c: Use string.h, not gdb_string.h.
* tilegx-linux-nat.c: Use string.h, not gdb_string.h.
* tilegx-tdep.c: Use string.h, not gdb_string.h.
* top.c: Use string.h, not gdb_string.h.
* tracepoint.c: Use string.h, not gdb_string.h.
* tui/tui-command.c: Use string.h, not gdb_string.h.
* tui/tui-data.c: Use string.h, not gdb_string.h.
* tui/tui-disasm.c: Use string.h, not gdb_string.h.
* tui/tui-file.c: Use string.h, not gdb_string.h.
* tui/tui-layout.c: Use string.h, not gdb_string.h.
* tui/tui-out.c: Use string.h, not gdb_string.h.
* tui/tui-regs.c: Use string.h, not gdb_string.h.
* tui/tui-source.c: Use string.h, not gdb_string.h.
* tui/tui-stack.c: Use string.h, not gdb_string.h.
* tui/tui-win.c: Use string.h, not gdb_string.h.
* tui/tui-windata.c: Use string.h, not gdb_string.h.
* tui/tui-winsource.c: Use string.h, not gdb_string.h.
* typeprint.c: Use string.h, not gdb_string.h.
* ui-file.c: Use string.h, not gdb_string.h.
* ui-out.c: Use string.h, not gdb_string.h.
* user-regs.c: Use string.h, not gdb_string.h.
* utils.c: Use string.h, not gdb_string.h.
* v850-tdep.c: Use string.h, not gdb_string.h.
* valarith.c: Use string.h, not gdb_string.h.
* valops.c: Use string.h, not gdb_string.h.
* valprint.c: Use string.h, not gdb_string.h.
* value.c: Use string.h, not gdb_string.h.
* varobj.c: Use string.h, not gdb_string.h.
* vax-tdep.c: Use string.h, not gdb_string.h.
* vaxnbsd-tdep.c: Use string.h, not gdb_string.h.
* vaxobsd-tdep.c: Use string.h, not gdb_string.h.
* windows-nat.c: Use string.h, not gdb_string.h.
* xcoffread.c: Use string.h, not gdb_string.h.
* xml-support.c: Use string.h, not gdb_string.h.
* xstormy16-tdep.c: Use string.h, not gdb_string.h.
* xtensa-linux-nat.c: Use string.h, not gdb_string.h.
Hi,
When I add another name of language, I find field 'la_name' can be
'const char *'. This patch is to constify it.
gdb:
2013-11-07 Yao Qi <yao@codesourcery.com>
* language.c (language_str): Return const char *.
(add_language): Add const to 'language_names'
* language.h (struct language_defn) <la_name>: Add const.
(language_str: Update declaration.
This is a follow-up series to move language stuff out of varobj.c.
This patch adds a new field la_varobj_ops in struct language_defn so
that each language has varobj-related options. Not every language
supports varobj, and the operations are identical to operations of c
languages.
'struct language_defn' is the ideal place to save all language-related
operations. After this patch, some cleanups can be done in patch 2/2,
which removes language-related stuff completely from varobj.c.
Regression tested on x86_64-linux.
gdb:
2013-10-25 Yao Qi <yao@codesourcery.com>
* language.h (struct lang_varobj_ops): Declare.
(struct language_defn) <la_varobj_ops>: New field.
* ada-lang.c: Include "varobj.h"
(defn ada_language_defn): Initialize field 'la_varobj_ops' by
ada_varobj_ops.
* c-lang.c: Include "varobj.h"
(c_language_defn): Initialize field 'la_varobj_ops' by
c_varobj_ops.
(cplus_language_defn): Initialize field 'la_varobj_ops' by
cplus_varobj_ops.
(asm_language_defn): Initialize field 'la_varobj_ops' by
default_varobj_ops.
(minimal_language_defn): Likewise.
* d-lang.c (d_language_defn): Likewise.
* f-lang.c (f_language_defn): Likewise.
* go-lang.c (go_language_defn): Likewise.
* m2-lang.c (m2_language_defn): Likewise.
* objc-lang.c (objc_language_defn): Likewise.
* opencl-lang.c (opencl_language_defn): Likewise.
* p-lang.c (pascal_language_defn): Likewise.
* language.c (unknown_language_defn): Likewise.
(auto_language_defn): Likewise.
(local_language_defn): Likewise.
* jv-lang.c (java_language_defn): Initialize field
'la_varobj_ops' by java_varobj_ops.
* varobj.c (varobj_create): Update.
* varobj.h (default_varobj_ops): Define macro.
* c-lang.c (cplus_language_defn): Use gdb_demangle.
* c-typeprint.c (c_type_print_base): Use gdb_demangle.
* cp-support.c (mangled_name_to_comp): Use gdb_demangle.
(gdb_demangle): New function.
* cp-support.h (gdb_demangle): Declare.
* dwarf2read.c (dwarf2_physname, fixup_partial_die)
(dwarf2_name): Use gdb_demangle.
* gdbtypes.c (check_stub_method): Use gdb_demangle.
* gnu-v3-abi.c (gnuv3_rtti_type): Strip @plt and version
suffixes from name.
(gnuv3_print_method_ptr): Use gdb_demangle.
* jv-lang.c (java_demangle): Use gdb_demangle.
* jv-typeprint.c (java_type_print_base): Use gdb_demangle.
* language.c (unk_lang_demangle): Use gdb_demangle.
* symtab.c (symbol_find_demangled_name)
(demangle_for_lookup): Use gdb_demangle.
Two modifications:
1. The addition of 2013 to the copyright year range for every file;
2. The use of a single year range, instead of potentially multiple
year ranges, as approved by the FSF.
The purpose of this patch is to better support renamings in the
"info locals" command. Consider ...
procedure Foo is
GV : Integer renames Pck.Global_Variable;
begin
Increment (GV); -- STOP
end Foo;
... Pck.Global_Variable is just an integer. After having stopped at
the "STOP" line, "info locals" yields:
(gdb) info locals
gv = <error reading variable gv (Cannot access memory at address 0xffffffffffffffff)>
In reality, two things are happening:
(1) Variable "GV" does not exist, which is normal, since there is
"GV" the renaming of another variable;
(2) But to allow the user access to that renaming the same way
the code has, the compiler produces an artificial variable
whose name encodes the renaming:
gv___XR_pck__global_variable___XE
For practical reasons, the artificial variable itself is given
irrelevant types and addresses.
But the "info locals" command does not act as if it was a short-cut
of "foreach VAR in locals, print VAR". Instead it gets the value of
each VAR directly, which does not work in this case, since the variable
is artificial and needs to be decoded first.
This patch makes the "read_var_value" routine language-specific.
The old implementation of "read_var_value" gets renamed to
"default_read_var_value" and all languages now use it (unchanged
behavior), except for Ada. In Ada, the new function ada_read_var_value
checks if we have a renaming, and if so, evaluates its value, or else
defers to default_read_var_value.
gdb/ChangeLog:
* language.h (struct language_defn): New "method" la_read_var_value.
* findvar.c: #include "language.h".
(default_read_var_value): Renames read_var_value. Rewrite
function description.
(read_var_value): New function.
* value.h (default_read_var_value): Add prototype.
* ada-lang.c (ada_read_renaming_var_value, ada_read_var_value):
New functions.
(ada_language_defn): Add entry for la_read_var_value.
* c-lang.c, d-lang.c, f-lang.c, jv-lang.c, language.c,
* m2-lang.c, objc-lang.c, opencl-lang.c, p-lang.c: Update
language_defn structures to add entry for new la_read_var_value
field.
The la_get_symbol_name_match_p language hook was poorly named, as
it suggested that the function should return nonzero if the names
match, whereas it is the exact opposite. This patch therefore
renames the hook and associated typedef, as well some of the code
that uses that hook.
gdb/ChangeLog:
* language.h (symbol_name_cmp_ftype): Renames
symbol_name_match_p_ftype.
(struct language_defn)[la_get_symbol_name_cmp]: Renames
la_get_symbol_name_match_p.
* ada-lang.c (ada_get_symbol_name_cmp): Renames
ada_get_symbol_name_match_p. Update comment.
(ada_language_defn)[la_get_symbol_name_cmp]: Update value.
* linespec.c (struct symbol_matcher_data)[symbol_name_cmp]:
Renames symbol_name_match_p. Update field type.
(iterate_name_matcher, iterate_over_all_matching_symtabs): Adjust.
* c-lang.c, d-lang.c, f-lang.c, jv-lang.c, m2-lang.c, objc-lang.c,
opencl-lang.c, p-lang.c: Replace "la_get_symbol_name_match_p" by
"la_get_symbol_name_cmp" in comments.
* language.c: Likewise.
This is the meat, where we replace the old la_symbol_name_compare
language method with the new ada_get_symbol_name_match_p.
It fixes the problem when trying to insert a breakpoint on "+".
gdb/ChangeLog:
* language.h (symbol_name_match_p_ftype): New typedef.
(struct language_defn): Replace field la_symbol_name_compare
by la_get_symbol_name_match_p.
* ada-lang.c (ada_get_symbol_name_match_p): New function.
(ada_language_defn): Use it.
* linespec.c (struct symbol_matcher_data): New type.
(iterate_name_matcher): Rewrite.
(iterate_over_all_matching_symtabs): Pass a pointer to
a symbol_matcher_data struct to expand_symtabs_matching
instead of just the lookup name.
* c-lang.c, d-lang.c, jv-lang.c, m2-lang.c, objc-lang.c,
opencl-lang.c, p-lang.c, language.c: Delete field
la_symbol_name_compare, and replace by NULL for new field
la_get_symbol_name_match_p.
* symfile.h (struct quick_symbol_functions): Update comment.