Commit Graph

44025 Commits

Author SHA1 Message Date
Pedro Alves 2f267673f0 gdb/tui: Prevent exceptions from trying to cross readline
This is triggered by simply scrolling off the end of the dissasembly
window.  This commit doesn't fix the actual exception that is being
thrown, which will still need to be fixed, but makes sure that we
don't ever throw an exception out to readline.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

        PR tui/9765
        * tui/tui-io.c (tui_getc): Rename to ...
        (tui_getc_1): ... this.
        (tui_get): New, reimplent as try/catch wrapper around tui_getc_1.

Change-Id: I2e32a401ab34404b2132ec82a3e1c17b9b723e41
2020-01-24 00:10:33 +00:00
Simon Marchi b3b3bada0d gdb: introduce objfile text_section_offset and data_section_offset methods
The pattern

  objfile->section_offsets[SECT_OFF_TEXT (objfile)]

... appears very often, to get the offset of the text section of an
objfile.  I thought it would be more readable to write it as:

  objfile->text_section_offset ()

... so I added this method and used it where possible.  I also added
data_section_offset, although it is not used as much.

gdb/ChangeLog:

	* objfiles.h (ALL_OBJFILE_OSECTIONS): Move up.
	(SECT_OFF_DATA): Likewise.
	(SECT_OFF_RODATA): Likewise.
	(SECT_OFF_TEXT): Likewise.
	(SECT_OFF_BSS): Likewise.
	(struct objfile) <text_section_offset, data_section_offset>: New
	methods.
	* amd64-windows-tdep.c (amd64_windows_find_unwind_info): Use
	objfile::text_section_offset.
	* coff-pe-read.c (add_pe_forwarded_sym): Likewise.
	* coffread.c (coff_symtab_read): Likewise.
	(enter_linenos): Likewise.
	(process_coff_symbol): Likewise.
	* ctfread.c (get_objfile_text_range): Likewise.
	* dtrace-probe.c (dtrace_probe::get_relocated_address):
	Use objfile::data_section_offset.
	* dwarf2-frame.c (execute_cfa_program): Use
	objfile::text_section_offset.
	(dwarf2_frame_find_fde): Likewise.
	* dwarf2read.c (create_addrmap_from_index): Likewise.
	(create_addrmap_from_aranges): Likewise.
	(dw2_find_pc_sect_compunit_symtab): Likewise.
	(process_psymtab_comp_unit_reader): Likewise.
	(add_partial_symbol): Likewise.
	(add_partial_subprogram): Likewise.
	(process_full_comp_unit): Likewise.
	(read_file_scope): Likewise.
	(read_func_scope): Likewise.
	(read_lexical_block_scope): Likewise.
	(read_call_site_scope): Likewise.
	(dwarf2_rnglists_process): Likewise.
	(dwarf2_ranges_process): Likewise.
	(dwarf2_ranges_read): Likewise.
	(dwarf_decode_lines_1): Likewise.
	(new_symbol): Likewise.
	(dwarf2_fetch_die_loc_sect_off): Likewise.
	(dwarf2_per_cu_text_offset): Likewise.
	* hppa-bsd-tdep.c (hppabsd_find_global_pointer): Likewise.
	* hppa-tdep.c (read_unwind_info): Likewise.
	* ia64-tdep.c (ia64_find_unwind_table): Likewise.
	* psympriv.h (struct partial_symtab): Likewise.
	* psymtab.c (find_pc_sect_psymtab): Likewise.
	* solib-svr4.c (enable_break): Likewise.
	* stap-probe.c (relocate_address): Use
	objfile::data_section_offset.
	* xcoffread.c (enter_line_range): Use
	objfile::text_section_offset.
	(read_xcoff_symtab): Likewise.
2020-01-23 17:55:35 -05:00
Simon Marchi ab53f38262 gdb: fix variable shadowing error in darwin-nat.c
We encounter this error when building on macOS with GCC.

  CXX    darwin-nat.o
/src-local/binutils-gdb/gdb/darwin-nat.c: In member function 'ptid_t darwin_nat_target::wait_1(ptid_t, target_waitstatus*)':
/src-local/binutils-gdb/gdb/darwin-nat.c:1264:18: error: declaration of 'inf' shadows a previous local [-Werror=shadow=compatible-local]
   for (inferior *inf : all_inferiors (this))
                  ^~~
/src-local/binutils-gdb/gdb/darwin-nat.c:1205:20: note: shadowed declaration is here
   struct inferior *inf;
                    ^~~

Fix it by moving the declaration of `inf` in the specific scopes that
need it.  I think it's clearer this way anyway, as it shows that it's
not the same `inf` that is used in these different scopes.

Thanks to Iain Sandoe for reporting this.  I did not see this error at
first, because I compile with the default system compiler on macOS,
which is clang.  The compiler flag we try to enable for this is
`-Wshadow=local`, which is not one recognized by clang.  I checked to
see if there would a version of the -Wshadow* warnings [1] we could
enable for clang, that would catch this, but the only one that would is
`-Wshadow` itself, and this is too invasive for us (which is why we
enabled just -Wshadow=local in the first place).

[1] https://clang.llvm.org/docs/DiagnosticsReference.html#wshadow

gdb/ChangeLog:

	* darwin-nat.c (darwin_nat_target::wait_1): Move `inf`
	declaration to narrower scopes.
2020-01-23 17:44:22 -05:00
Simon Marchi e7eee665a1 gdb: fix darwin-nat.c build / adapt to multi-target
The darwin-nat.c file doesn't build since the multi-target changes
(5b6d1e4f, "Multi-target support").  This patch makes it build.  I have
access to a macOS vm, so I am able to build it, but I wasn't able to
successfully codesign it and try to actually debug something, so I don't
know if it works.  I don't have much more time to put on this to figure
it out, so I thought I'd sent the patch anyway, as it's at least a step
in the right direction.

The bulk of the patch is to change a bunch of functions to be methods of
the darwin_nat_target object, so that this can pass `this` to
find_inferior_ptid and other functions that now require a
process_stratum_target pointer.

The darwin_ptrace_him function (renamed to darwin_nat_target::ptrace_him
in this patch) is passed to fork_inferior as the `init_trace_fun`
parameter.  Since the method can't be passed as a plain function pointer
(we need the `this` pointer), I changed the `init_trace_fun` parameter
of fork_inferior to be a gdb::function_view, so we can pass a lambda and
capture `this`.

The changes in darwin-nat.h are only to move definition higher in the
file, so that forward declarations are not needed.

gdb/ChangeLog:

	* darwin-nat.h (struct darwin_exception_msg, enum
	darwin_msg_state, struct darwin_thread_info, darwin_thread_t):
	Move up.
	(class darwin_nat_target) <wait_1, check_new_threads,
	decode_exception_message, decode_message, stop_inferior,
	init_thread_list, ptrace_him, cancel_breakpoint>: Declare.
	* darwin-nat.c (darwin_check_new_threads): Rename to...
	(darwin_nat_target::check_new_threads): ... this.
	(darwin_suspend_inferior_it): Remove.
	(darwin_decode_exception_message): Rename to...
	(darwin_nat_target::decode_exception_message): ... this.
	(darwin_nat_target::resume): Pass target to find_inferior_ptid.
	(darwin_decode_message): Rename to...
	(darwin_nat_target::decode_message): ... this.
	(cancel_breakpoint): Rename to...
	(darwin_nat_target::cancel_breakpoint): ... this.
	(darwin_wait): Rename to...
	(darwin_nat_target::wait_1): ... this.  Use range-based for loop
	instead of iterate_over_inferiors.
	(darwin_nat_target::wait): Call wait_1 instead of darwin_wait.
	(darwin_stop_inferior): Rename to...
	(darwin_nat_target::stop_inferior): ... this.
	(darwin_nat_target::kill): Call wait_1 instead of darwin_wait.
	(darwin_init_thread_list): Rename to...
	(darwin_nat_target::init_thread_list): ... this.
	(darwin_ptrace_him): Rename to...
	(darwin_nat_target::ptrace_him): ... this.
	(darwin_nat_target::create_inferior): Pass lambda function to
	fork_inferior.
	(darwin_nat_target::detach): Call stop_inferior instead of
	darwin_stop_inferior.
	* fork-inferior.h (fork_inferior): Change init_trace_fun
	parameter to gdb::function_view.
	* fork-inferior.c (fork_inferior): Likewise.
2020-01-23 14:55:50 -05:00
Hannes Domani c162ed3e66 Cache the text section offset of shared libraries
Each time a dll is loaded, update_solib_list is called.
This in turn calls deep down xfer_partial -> windows_xfer_shared_libraries,
which calls windows_xfer_shared_library for each loaded dll,
and pe_text_section_offset reads the dll for the text section offset.

Also if the data provided by xfer_partial is bigger than 4K,
then all of this is done for each 4K chunk (see target_read_alloc_1).

Caching of the text section offset improves the startup time of
an application with >300 dynamically loaded plugins from 2m10s to 10s.
And the shutdown time improves from 2m to 2s.

gdb/ChangeLog:

2020-01-23  Hannes Domani  <ssbssa@yahoo.de>

	* i386-cygwin-tdep.c (core_process_module_section): Update.
	* windows-nat.c (struct lm_info_windows): Add text_offset.
	(windows_xfer_shared_libraries): Update.
	* windows-tdep.c (windows_xfer_shared_library):
	Add text_offset_cached argument.
	* windows-tdep.h (windows_xfer_shared_library): Update.
2020-01-23 18:44:27 +01:00
Simon Marchi a12378729f gdb: add declaration for _initialize_gdbarch in gdbarch.sh
In commit

  gdb: add back declarations for _initialize functions
  6c2659886f

I wrongfully edited gdbarch.c, instead of editing gdbarch.sh and
re-generating gdbarch.c.  This patch fixes gdbarch.sh to add a
declaration for _initialize_gdbarch.  gdbarch.c is not changed, as the
output of gdbarch.sh now matches the current state of gdbarch.c.

gdb/ChangeLog:

	* gdbarch.sh: Add declaration for _initialize_gdbarch.
2020-01-21 18:30:25 -05:00
Simon Marchi b3ee6dd9f2 gdb: remove uses of iterate_over_inferiors in remote-sim.c
This removes the two uses of iterate_over_inferiors, in favor of
range-based loops.

gdb/ChangeLog:

	* remote-sim.c (check_for_duplicate_sim_descriptor): Remove.
	(get_sim_inferior_data): Remove use of iterate_over_inferiors,
	replace with range-based for.
	(gdbsim_interrupt_inferior): Remove.
	(gdbsim_target::interrupt): Replace iterate_over_inferiors use
	with a range-based for.  Inline code from
	gdbsim_interrupt_inferior.
2020-01-21 16:28:26 -05:00
Simon Marchi f9fac3c81b gdb: fix indentation in infrun.c
I noticed the indentation there was off, this patch fixes it.

gdb/ChangeLog:

	* infrun.c (proceed): Fix indentation.
2020-01-21 16:04:51 -05:00
Tom Tromey f6474de9aa Allow use of Pygments to colorize source code
While GNU Source Highlight is good, it's also difficult to build and
distribute.  For one thing, it needs Boost.  For another, it has an
unusual configuration and installation setup.

Pygments, a Python library, doesn't suffer from these issues, and so I
thought it would be a reasonable fallback.

This patch implements this idea.  GNU Source Highlight is preferred,
but if it is unavailable (or fails), the extension languages are
tried.  This patch also implements support for Pygments.

Something similar could be done for Guile, using:

    https://dthompson.us/projects/guile-syntax-highlight.html

However, I don't know enough about Guile internals to make this
happen, so I have not done it here.

gdb/ChangeLog
2020-01-21  Tom Tromey  <tromey@adacore.com>

	* source-cache.c (source_cache::ensure): Call ext_lang_colorize.
	* python/python.c (python_extension_ops): Update.
	(gdbpy_colorize): New function.
	* python/lib/gdb/__init__.py (colorize): New function.
	* extension.h (ext_lang_colorize): Declare.
	* extension.c (ext_lang_colorize): New function.
	* extension-priv.h (struct extension_language_ops) <colorize>: New
	member.
	* cli/cli-style.c (_initialize_cli_style): Update help text.

Change-Id: I5e21623ee05f1f66baaa6deaeca78b578c031bf4
2020-01-21 12:39:17 -07:00
Luis Machado f0c702d4b8 Convert an int flag variable to bool
As suggested, the cond variable is really supposed to be a bool. So,
make it so.

gdb/ChangeLog:

2020-01-21  Luis Machado  <luis.machado@linaro.org>

	* aarch64-tdep.c (struct aarch64_displaced_step_closure)
	<cond>: Change type to bool.
	(aarch64_displaced_step_b_cond): Update cond to use bool type.
	(aarch64_displaced_step_cb): Likewise.
	(aarch64_displaced_step_tb): Likewise.
2020-01-21 10:26:27 -03:00
Luis Machado 1ab139e5be Add more debugging output to aarch64_displaced_step_fixup
While debugging the step-over-syscall problem, i wanted to see a bit more
debugging output to try to determine the root cause.

This patch does this.

gdb/ChangeLog:

2020-01-21  Luis Machado  <luis.machado@linaro.org>

	* aarch64-tdep.c (aarch64_displaced_step_fixup): Add more debugging
	output.
2020-01-21 10:25:54 -03:00
Luis Machado 0c27188999 Fix step-over-syscall.exp failure
In particular, this one:

FAIL: gdb.base/step-over-syscall.exp: fork: displaced=on: check_pc_after_cross_syscall: single step over fork final pc

When ptrace fork event reporting is enabled, GDB gets a PTRACE_EVENT_FORK
event whenever the inferior executes the fork syscall.

Then the logic is that GDB needs to step the inferior yet again in order to
receive a predetermined SIGTRAP, but no execution takes place because the
signal was already queued for delivery. That means the PC should stay the same.

I noticed the aarch64 code is currently adjusting the PC in this situation,
making the inferior skip an instruction without executing it.

The following change checks if we did not execute the instruction
(pc - to == 0), making proper adjustments for such case.

Regression tested on aarch64-linux-gnu on the tryserver.

gdb/ChangeLog:

2020-01-21  Luis Machado  <luis.machado@linaro.org>

	* aarch64-tdep.c (struct aarch64_displaced_step_closure )
	<pc_adjust>: Adjust the documentation.
	(aarch64_displaced_step_fixup): Check if PC really moved before
	adjusting it.
2020-01-21 10:25:15 -03:00
Simon Marchi cf1d9e092f sim: don't rely on inferior_ptid in gdbsim_target::wait
When running a program with the simulator target, I get:

    /home/simark/src/binutils-gdb/gdb/inferior.c:279: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.

This can be reproduced by building a GDB for --target=arm-none-gnueabi,
and running with

    $ ./gdb -nx --data-directory=data-directory a.out -ex "target sim" -ex load -ex "b main" -ex r

Where a.out is any program with a main.

The problem is that gdbsim_target::wait assumes that inferior_ptid has
the value of the thread it wants to report an event for.

Actually, it's the target's responsibility to come up with the ptid of
the thread the event is for.  In the sim target, that ptid is stored in
sim_inferior_data::remote_sim_ptid, so return that instead of
inferior_ptid.

ChangeLog:

	* remote-sim.c (gdbsim_target::wait): Return
	sim_data->remote_sim_ptid instead of inferior_ptid.
2020-01-19 19:48:16 -05:00
Tom Tromey 4d89c1c79f Call disassemble_free_target in gdb
Commit 20135676fc ("PR24960, Memory leak
from disassembler") added "disassemble_free_target" to opcodes.  This
is used to free target-specific data when finished with a
disassembler.

This patch changes gdb to call this function where needed.

gdb/ChangeLog
2020-01-19  Tom Tromey  <tom@tromey.com>

	* disasm.c (~gdb_disassembler): New destructor.
	(gdb_buffered_insn_length): Call disassemble_free_target.
	* disasm.h (class gdb_disassembler): Declare destructor.  Use
	DISABLE_COPY_AND_ASSIGN.

Change-Id: I245ba5b7dec5e5d9f29cd21832c6e2b4fecef047
2020-01-19 13:24:32 -07:00
Tom Tromey c0ab21c22b Replace init_cutu_and_read_dies with a class
init_cutu_and_read_dies takes a callback function, which I've always
found somewhat difficult to follow.  This patch replaces this function
with a class, and changes the callers to use it.  In some cases this
allows for the removal of a helper struct and helper function as well.

gdb/ChangeLog
2020-01-19  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (abbrev_table_up): Move typedef earlier.
	(die_reader_func_ftype): Remove.
	(cutu_reader): New class.
	(dw2_get_file_names_reader): Remove "data" parameter.
	(dw2_get_file_names): Use cutu_reader.
	(create_debug_type_hash_table): Update.
	(read_cutu_die_from_dwo): Update comment.
	(lookup_dwo_unit): Add dwo_name parameter.
	(cutu_reader::init_tu_and_read_dwo_dies): Now a method.  Remove
	die_reader_func_ftype and data parameters.
	(cutu_reader::cutu_reader): Rename from init_cutu_and_read_dies.
	Remove die_reader_func_ftype and data parameters.
	(~cutu_reader): New; from init_cutu_and_read_dies.
	(cutu_reader::cutu_reader): Rename from
	init_cutu_and_read_dies_no_follow.  Remove die_reader_func_ftype
	and data parameters.
	(init_cutu_and_read_dies_simple): Remove.
	(struct process_psymtab_comp_unit_data): Remove.
	(process_psymtab_comp_unit_reader): Remove data parameter; add
	want_partial_unit and pretend_language parameters.
	(process_psymtab_comp_unit): Use cutu_reader.
	(build_type_psymtabs_reader): Remove data parameter.
	(build_type_psymtabs_1): Use cutu_reader.
	(process_skeletonless_type_unit): Likewise.
	(load_partial_comp_unit_reader): Remove.
	(load_partial_comp_unit): Use cutu_reader.
	(load_full_comp_unit_reader): Remove.
	(load_full_comp_unit): Use cutu_reader.
	(struct create_dwo_cu_data): Remove.
	(create_dwo_cu_reader): Remove datap parameter; add dwo_file and
	dwo_unit parameters.
	(create_cus_hash_table): Use cutu_reader.
	(struct dwarf2_read_addr_index_data): Remove.
	(dwarf2_read_addr_index_reader): Remove.
	(dwarf2_read_addr_index): Use cutu_reader.
	(read_signatured_type_reader): Remove.
	(read_signatured_type): Use cutu_reader.

Change-Id: I4ef2f29e73108ce94bfe97799f8f638ed272212d
2020-01-19 13:16:25 -07:00
Tom Tromey 45bbae5c4b Remove flickering from the TUI
In some cases, the TUI flickers when redrawing.  This can be seen
mostly easily when switching layouts.

This patch fixes the problem by exploiting the double buffering that
curses already does.  In some spots, the TUI will now disable flushing
the curses buffers to the screen; and then flush them all at once when
the rendering is complete.

gdb/ChangeLog
2020-01-19  Tom Tromey  <tom@tromey.com>

	* tui/tui.c (tui_show_assembly): Use tui_suppress_output.
	* tui/tui-wingeneral.h (class tui_suppress_output): New.
	(tui_wrefresh): Declare.
	* tui/tui-wingeneral.c (suppress_output): New global.
	(tui_suppress_output, ~tui_suppress_output): New constructor and
	destructor.
	(tui_wrefresh): New function.
	(tui_gen_win_info::refresh_window): Use tui_wrefresh.
	(tui_gen_win_info::make_window): Call wnoutrefresh when needed.
	* tui/tui-regs.h (struct tui_data_window) <no_refresh>: Declare
	method.
	* tui/tui-regs.c (tui_data_window::erase_data_content): Call
	tui_wrefresh.
	(tui_data_window::no_refresh): New method.
	(tui_data_item_window::refresh_window): Call tui_wrefresh.
	(tui_reg_command): Use tui_suppress_output
	* tui/tui-layout.c (tui_set_layout): Use tui_suppress_output.
	* tui/tui-data.h (struct tui_gen_win_info) <no_refresh>: New
	method.
	* tui/tui-command.c (tui_refresh_cmd_win): Call tui_wrefresh.

Change-Id: Icb832ae100b861de3af3307488e636fa928d5c9f
2020-01-19 13:08:49 -07:00
Tom Tromey 4f13c1c00b Make "file" clear TUI source window
I noticed that a plain "file" will leave the current source file in
the TUI source window.  Instead, I think, it should clear the source
window.  This patch implements this.

gdb/ChangeLog
2020-01-19  Tom Tromey  <tom@tromey.com>

	* tui/tui-winsource.c (tui_update_source_windows_with_line):
	Handle case where symtab is null.

gdb/testsuite/ChangeLog
2020-01-19  Tom Tromey  <tom@tromey.com>

	* gdb.tui/main.exp: Add check for plain "file".

Change-Id: I8424acf837f1a47f75bc6a833d1e917d4c10b51e
2020-01-19 13:08:48 -07:00
Simon Marchi fa47e4463a gdb/linux-fork: simplify one_fork_p
Unless I'm missing something, this function is a complicated way of
saying "fork_list.size () == 1".

gdb/ChangeLog:

	* linux-fork.c (one_fork_p): Simplify.
2020-01-19 11:54:02 -05:00
Simon Marchi 26f42329ca gdb: remove uses of iterate_over_inferiors in top.c
Replace with range-based for loops.

gdb/ChangeLog:

	* top.c (struct qt_args): Remove.
	(kill_or_detach): Change return type to void, replace `void *`
	parameter with a proper one.
	(print_inferior_quit_action):  Likewise.
	(quit_confirm): Use range-based for loop to iterate over inferiors.
	(quit_force): Likewise.
2020-01-17 09:59:10 -05:00
Simon Marchi a9ac81b1a7 gdb: remove uses of iterate_over_inferiors in mi/mi-main.c
Replace with range-based loops.

gdb/ChangeLog:

	* mi/mi-main.c (run_one_inferior): Change return type to void, replace
	`void *` parameter with proper parameters.
	(mi_cmd_exec_run): Use range-based loop to iterate over inferiors.
	(print_one_inferior): Change return type to void, replace `void *`
	parameter with proper parameters.
	(mi_cmd_list_thread_groups): Use range-based loop to iterate over
	inferiors.
	(get_other_inferior): Remove.
	(mi_cmd_remove_inferior): Use range-based loop to iterate over
	inferiors.
2020-01-17 09:57:58 -05:00
Simon Marchi 788eca4949 gdb: remove use of iterate_over_inferiors in mi/mi-interp.c
Replace it with a range-based for.  I've updated the comment in
mi_interp::init, which was a bit stale.

gdb/ChangeLog:

	* mi/mi-interp.c (report_initial_inferior): Remove.
	(mi_interp::init): Use range-based for to iterate over inferiors.
2020-01-17 09:57:08 -05:00
Simon Marchi d9bc85b65b gdb: remove use of iterate_over_inferiors in py-inferior.c
Use range-based for instead of iterate_over_inferiors in one spot in the Python
code.

gdb/ChangeLog:

	* python/py-inferior.c (build_inferior_list): Remove.
	(gdbpy_ref): Use range-based for loop to iterate over inferiors.
2020-01-17 09:51:10 -05:00
Christian Biesinger 40c9409927 Fix some spelling errors.
I noticed those from a lintian run:
https://salsa.debian.org/cbiesinger-guest/gdb/-/jobs/514119

gdb/ChangeLog:

2020-01-16  Christian Biesinger  <cbiesinger@google.com>

        * btrace.c (btrace_compute_ftrace_1): Fix spelling error (Unkown).
        (btrace_stitch_trace): Likewise.
        * charset.c (intermediate_encoding): Likewise (vaild).
        * nat/linux-btrace.c (linux_read_pt): Likewise (Unkown).
        * python/py-record-btrace.c (struct PyMethodDef): Likewise (occurences).
        * record-btrace.c (record_btrace_print_conf): Likewise (unkown).

gdb/testsuite/ChangeLog:

2020-01-16  Christian Biesinger  <cbiesinger@google.com>

        * lib/gdb.exp: Fix spelling error (seperatelly).

Change-Id: I2a44936bac295020f217fb6c78b99b0a8d09cf9a
2020-01-16 16:46:25 -06:00
Hannes Domani e0cdfe3c14 Add type for $_tlb->process_environment_block->process_parameters
The type then looks like this:

(gdb) pt $_tlb->process_environment_block->process_parameters
type = struct rtl_user_process_parameters {
    DWORD32 maximum_length;
    DWORD32 length;
    DWORD32 flags;
    DWORD32 debug_flags;
    void *console_handle;
    DWORD32 console_flags;
    void *standard_input;
    void *standard_output;
    void *standard_error;
    unicode_string current_directory;
    void *current_directory_handle;
    unicode_string dll_path;
    unicode_string image_path_name;
    unicode_string command_line;
    void *environment;
    DWORD32 starting_x;
    DWORD32 starting_y;
    DWORD32 count_x;
    DWORD32 count_y;
    DWORD32 count_chars_x;
    DWORD32 count_chars_y;
    DWORD32 fill_attribute;
    DWORD32 window_flags;
    DWORD32 show_window_flags;
    unicode_string window_title;
    unicode_string desktop_info;
    unicode_string shell_info;
    unicode_string runtime_data;
} *

It's mainly useful to get the current directory, or the full command line:

(gdb) p $_tlb->process_environment_block->process_parameters->current_directory
$1 = {
  length = 26,
  maximum_length = 520,
  buffer = 0xe36c8 L"C:\\src\\tests\\"
}
(gdb) p $_tlb->process_environment_block->process_parameters->command_line
$2 = {
  length = 94,
  maximum_length = 96,
  buffer = 0xe32aa L"\"C:\\gdb\\build64\\gdb-git\\gdb\\gdb.exe\" access.exe"
}

The type names are all lowercase because the existing types created
by windows_get_tlb_type are also lowercase.

Type unicode_string is documented at [1].
The official documentation [2] for rtl_user_process_parameters is limited,
so I've used this other page [3].

[1] https://docs.microsoft.com/en-us/windows/win32/api/ntdef/ns-ntdef-_unicode_string
[2] https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-rtl_user_process_parameters
[3] https://www.nirsoft.net/kernel_struct/vista/RTL_USER_PROCESS_PARAMETERS.html

gdb/ChangeLog:

2020-01-16  Hannes Domani  <ssbssa@yahoo.de>

	* windows-tdep.c (windows_get_tlb_type):
	Add rtl_user_process_parameters type.
2020-01-16 21:14:47 +01:00
Pedro Alves 790f17188a Ensure proc-service symbols have default visibility (PR build/24805)
Compiling GDB with '-fvisibility=hidden' removes the symbols that
should be exported.

This patch explicitly marks them as visible.

gdb/ChangeLog:
2020-01-16  Pedro Alves  <palves@redhat.com>
            Norbert Lange  <nolange79@gmail.com>

	PR build/24805
	* gdbsupport/gdb_proc_service.h (PS_EXPORT): New.
	(ps_get_thread_area, ps_getpid, ps_lcontinue, ps_lgetfpregs)
	(ps_lgetregs, ps_lsetfpregs, ps_lsetregs, ps_lstop, ps_pcontinue)
	(ps_pdread, ps_pdwrite, ps_pglobal_lookup, ps_pstop, ps_ptread)
	(ps_ptwrite, ps_lgetxregs, ps_lgetxregsize, ps_lsetxregs)
	(ps_plog): Redeclare exported functions with default visibility.
2020-01-16 19:14:14 +00:00
Pedro Alves 701adfb009 [gdb] Move ChangeLog entries to their right files
I spotted a few misplaced entries in the ChangeLog-2019 entries, and
went on to fix them.

Looking around I saw a good number of other entries in other years.
Then OCD got the best of me and I fixed them all.

Also fixes cases of wrong paths in entries, like "* gdb/foo.c" instead
of "* foo.c".
2020-01-16 18:11:06 +00:00
Nitika Achra 3112ed9799 Support for DWARF5 location lists entries
This patch handles DW_LLE_base_addressx, DW_LLE_startx_length and
DW_LLE_start_length.

Tested by running the testsuite before and after the patch and there is
no increase in the number of test cases that fails. Tested with both
-gdwarf-4 and -gdwarf-5 flags. Also tested -gslit-dwarf along with
-gdwarf-4 as well as -gdwarf5 flags.

This is an effort to support DWARF5 in gdb.

gdb/ChangeLog:

	* dwarf2loc.c (decode_debug_loclists_addresses): Handle
	DW_LLE_base_addressx, DW_LLE_startx_length, DW_LLE_start_length.
2020-01-16 11:51:19 -05:00
Simon Marchi 8dc3273e0c Use get_thread_regcache instead of get_current_regcache in post_create_inferior
In post_create_inferior, we get the current thread using the
inferior_thread function and store it in `thr`.  We then call
get_current_regcache immediately after, which does:

  return get_thread_regcache (inferior_thread ());

This patch makes post_create_inferior use get_thread_regcache, passing
`thr`, saving an unnecessary inferior_thread call.

gdb/ChangeLog:

	* infcmd.c (post_create_inferior): Use get_thread_regcache
	instead of get_current_regcache.
2020-01-15 12:47:44 -05:00
Tom Tromey ff47f4f06d Fix valgrind error from gdb.decode_line
PR symtab/12535 points out that gdb.decode_line("") will cause a
valgrind report.

I think the empty linespec does not really make sense.  So, this patch
changes gdb.decode_line to treat a whitespace-only linespec the same
as a non-existing argument.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	PR symtab/12535:
	* python/python.c (gdbpy_decode_line): Treat empty string the same
	as no argument.

gdb/testsuite/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	PR symtab/12535:
	* gdb.python/python.exp: Test decode_line with empty string
	argument.

Change-Id: I1d95812b4b7a21d69a3e9afd05b9e3141a931897
2020-01-14 17:57:52 -07:00
Tom Tromey 975f45b7e1 Don't link gdb twice against libiberty
I noticed that gdb includes libiberty twice in its link line.  I don't
think there's a need for this, so this patch removes one of the
references.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* Makefile.in (CLIBS): Remove second use of $(LIBIBERTY).

Change-Id: I43bb7100660867081f937c67ea70ff751c62bbfb
2020-01-14 16:25:04 -07:00
Tom Tromey 25e5735653 Remove use of <config.h> from gdb/nat/
This removes the use of <config.h> from the files in gdb/nat/.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* nat/linux-btrace.c: Don't include <config.h>.
	* nat/linux-ptrace.c: Don't include <config.h>.
	* nat/x86-linux-dregs.c: Don't include <config.h>.

Change-Id: Ie8c734c54ada848aa020c77ec727704d367eff81
2020-01-14 16:25:04 -07:00
Tom Tromey 05ea2a0510 Move many configure checks to common.m4
This moves many needed configure checks from gdb and gdbserver into
common.m4.  This helps gdbsupport, nat, and target be self-contained.

The result is a bit spaghetti-ish, because gdbsupport uses another m4
file from gdb/.  The resulting code is somewhat non-obvious.  However,
these problems already exist, so it's not really that much worse than
what is already done.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Move many checks to ../gdbsupport/common.m4.

gdb/gdbserver/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Remove any checks that were added to common.m4.
	* acinclude.m4: Include lib-ld.m4, lib-prefix.m4, and
	lib-link.m4.

gdbsupport/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure, Makefile.in, aclocal.m4, common.m4, config.in:
	Rebuild.
	* common.m4 (GDB_AC_COMMON): Move many checks from
	gdb/configure.ac.
	* acinclude.m4: Include bfd.m4, ptrace.m4.

Change-Id: I931eaa94065df268b30a2f1354390710df89c7f8
2020-01-14 16:25:03 -07:00
Tom Tromey 01027315f5 Move gdbsupport to the top level
This patch moves the gdbsupport directory to the top level.  This is
the next step in the ongoing project to move gdbserver to the top
level.

The bulk of this patch was created by "git mv gdb/gdbsupport gdbsupport".

This patch then adds a build system to gdbsupport and wires it into
the top level.  Then it changes gdb to use the top-level build.

gdbserver, on the other hand, is not yet changed.  It still does its
own build of gdbsupport.

ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gdbsupport.
	* MAINTAINERS: Add gdbsupport.
	* configure: Rebuild.
	* configure.ac (configdirs): Add gdbsupport.
	* gdbsupport: New directory, move from gdb/gdbsupport.
	* Makefile.def (host_modules, dependencies): Add gnulib.
	* Makefile.in: Rebuild.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* nat/x86-linux-dregs.c: Include configh.h.
	* nat/linux-ptrace.c: Include configh.h.
	* nat/linux-btrace.c: Include configh.h.
	* defs.h: Include config.h, bfd.h.
	* configure.ac: Don't source common.host.
	(CONFIG_OBS, CONFIG_SRCS): Remove gdbsupport files.
	* configure: Rebuild.
	* acinclude.m4: Update path.
	* Makefile.in (SUPPORT, LIBSUPPORT, INCSUPPORT): New variables.
	(CONFIG_SRC_SUBDIR): Remove gdbsupport.
	(INTERNAL_CFLAGS_BASE): Add INCSUPPORT.
	(CLIBS): Add LIBSUPPORT.
	(CDEPS): Likewise.
	(COMMON_SFILES): Remove gdbsupport files.
	(HFILES_NO_SRCDIR): Likewise.
	(stamp-version): Update path to create-version.sh.
	(ALLDEPFILES): Remove gdbsupport files.

gdb/gdbserver/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* server.h: Include config.h.
	* gdbreplay.c: Include config.h.
	* configure: Rebuild.
	* configure.ac: Don't source common.host.
	* acinclude.m4: Update path.
	* Makefile.in (INCSUPPORT): New variable.
	(INCLUDE_CFLAGS): Add INCSUPPORT.
	(SFILES): Update paths.
	(version-generated.c): Update path to create-version.sh.
	(gdbsupport/%-ipa.o, gdbsupport/%.o): Update paths.

gdbsupport/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* common-defs.h: Add GDBSERVER case.  Update includes.
	* acinclude.m4, aclocal.m4, config.in, configure, configure.ac,
	Makefile.am, Makefile.in, README: New files.
	* Moved from ../gdb/gdbsupport/

Change-Id: I07632e7798635c1bab389bf885971e584fb4bb78
2020-01-14 16:25:02 -07:00
Tom Tromey b2ceabe8f0 Consolidate definition of USE_WIN32API
I noticed that USE_WIN32API is defined separately by gdbserver and
gdb.  However, because it is used by code in gdbsupport, it should be
defined by common.m4.  This approach ensures that the code will
continue to work when it is moved to the top level.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* gdbsupport/common.m4 (GDB_AC_COMMON): Define WIN32APILIBS and
	USE_WIN32API when needed.
	* configure.ac (USE_WIN32API): Don't define.
	(WIN32LIBS): Use WIN32APILIBS.
	* configure: Rebuild.

gdb/gdbserver/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure.ac (LIBS): Use WIN32APILIBS.
	(USE_WIN32API): Don't define.
	* configure: Rebuild.

Change-Id: I40d524d5445ebfb452b36f4d0e102f0b1e1089df
2020-01-14 16:25:02 -07:00
Tom Tromey 25c51f71d5 Fix indentation in common.m4
Simon pointed out that the indentation in common.m4 is off.  This
patch fixes the problem.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* gdbsupport/common.m4 (GDB_AC_COMMON): Fix indentation.

gdb/gdbserver/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

Change-Id: I6a629bd5873cca95ba3e17656f0d0ce583a08361
2020-01-14 16:16:39 -07:00
Bernd Edlinger 717c684dd1 Make skip without argument skip the current inline function
Previously always the outermost function block was used, but
since skip is now able to skip over inline functions it is more
natural to skip the inline function that the program is currently
executing.

gdb:
2020-01-14  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* skip.c (skip_function_command): Make skip w/o arguments use the
	name of the inlined function if pc is inside any inlined function.

gdb/testsuite:
2020-01-14  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gdb.base/skip-inline.exp: Extend test.
2020-01-14 21:20:16 +01:00
Luis Machado 7da6a5b938 Fix/Update misc comments
While doing some investigation of mine, i noticed a few typos,
inaccuracies and missing information.

I went ahead and updated/improved those.

gdb/ChangeLog:

2020-01-14  Luis Machado  <luis.machado@linaro.org>

	* inf-ptrace.c (inf_ptrace_target::resume): Update comments.
	* infrun.c (resume_1): Likewise.
	(handle_inferior_event): Remove stale comment.
	* linux-nat.c (linux_nat_target::resume): Update comments.
	(save_stop_reason): Likewise.
	(linux_nat_filter_event): Likewise.
	* linux-nat.h (struct lwp_info) <stop_pc>, <stop_reason>: Likewise.
2020-01-14 11:17:26 -03:00
Andrew Burgess 44e4c7757a gdb: Handle malformed ELF, symbols in non-allocatable sections
I ended up debugging a malformed ELF where a section containing
executable code was not correctly marked as allocatable.  Before
realising the ELF was corrupted I tried to place a breakpoint on a
symbol in the non-allocatable, executable section, and GDB crashed.

Though trying to debug such an ELF clearly isn't going to go well I
would prefer, as far as possible, that any input, no matter how
corrupted, not crash GDB.

The crash occurs when trying to set a breakpoint on the name of a
function from the corrupted section.  GDB converts the symbol to a
symtab_and_line, and looks up a suitable section for this.

The problem is that the section is actually an obj_section, which is
stored in the table within the objfile, and we only initialise this
table for allocatable sections (see add_to_objfile_sections_full in
objfiles.c).  So, if the symbol is in a non-allocatable section then
we end up referencing an uninitialised obj_section.

Later we call get_sal_arch on the symtab_and_line, which calls
get_objfile_arch, which uses the objfile from the uninitialised
obj_section, which will be nullptr, at which point GDB crashes.

The fix I propose here is that when we setup the section references on
msymbols, we should check if the bfd_section being referenced is
allocatable or not.  If it is not then we should set the section
reference back to the default 0 section (see how MSYMBOL_OBJ_SECTION
and SYMBOL_OBJ_SECTION treat the 0 section index).

With this fix in place GDB no longer crashes.  Instead GDB creates the
breakpoint at the non-allocated address, and then fails, with an
error, when it tries to insert the breakpoint.

gdb/ChangeLog:

	* elfread.c (record_minimal_symbol): Set section index to 0 for
	non-allocatable sections.

gdb/testsuite/ChangeLog:

	* gdb.dwarf2/dw2-bad-elf-other.S: New file.
	* gdb.dwarf2/dw2-bad-elf.c: New file.
	* gdb.dwarf2/dw2-bad-elf.exp: New file.

Change-Id: Ie05436ab4c6a71440304d20ee639dfb021223f8b
2020-01-13 23:57:42 +00:00
Andrew Burgess d93c6db74b gdb/testsuite: Allow DWARF assembler to create multiple line tables
Fixes a bug in the DWARF assembler that prevents multiple line tables
from being created in a test.  We currently don't initialise a couple
of flags, as a result we will only ever generate one end of file list,
and one end of header, in the first line table.  Any additional line
tables will be missing these parts, and will therefore be corrupt.

This fix will be required for a later commit.  There should be no
change in the testsuite after this commit.

gdb/testsuite/ChangeLog:

	* lib/dwarf.exp (Dwarf::lines): Reset _line_saw_program and
	_line_saw_file.

Change-Id: Id7123f217a036f26ee32d608db3064dd43164596
2020-01-13 23:56:02 +00:00
Ali Tamur 18a8505e38 Dwarf 5: Handle debug_str_offsets and indexed attributes that have base offsets.
* Process debug_str_offsets section. Handle DW_AT_str_offsets_base attribute and
keep the value in dwarf2_cu.

* Make addr_base field in dwarf2_cu optional to disambiguate 0 value
(absent or present and 0).

* During parsing, there is no guarantee that DW_AT_str_offsets_base and
DW_AT_rnglists_base fields will be processed before the attributes that need
those values for correct computation. So make two passes, on the first one mark
the attributes that depend on *_base attributes and process only the others.
On the second pass, only process the attributes that are marked on the first
pass.

* For string attributes, differentiate between addresses that directly point to
a string and those that point to an offset in debug_str_offsets section.

* There are now two attributes, DW_AT_addr_base and DW_AT_GNU_addr_base to read
address offset base. Likewise, there are two attributes, DW_AT_rnglists_base
and DW_AT_GNU_ranges_base to read ranges base. Since there is no guarantee which
ones the compiler will generate, create helper functions to handle all cases.

Tested with CC=/usr/bin/gcc (version 8.3.0) against master branch (also with
-gsplit-dwarf and -gdwarf-4 flags) and there was no increase in the set of
tests that fails. (gdb still cannot debug a 'hello world' program with DWARF 5,
so for the time being, this is all we care about).

This is part of an effort to support DWARF-5 in gdb.
2020-01-13 15:35:35 -08:00
Simon Marchi 0cac9354bf gdb: use gdb::byte_vector instead of std::vector<char> in core_target::get_core_register_section
Since the data held by the `contents` variable is arbitrary binary data,
it should have gdb_byte elements, not char elements.  Also, using
gdb::byte_vector is preferable, since it doesn't unnecessarily
zero-initialize the values.

Instead of adding a cast in the call to m_core_vec->core_read_registers,
I have changed core_read_registers' argument to be a gdb_byte* instead
of a char*.

gdb/ChangeLog:

	* gdbcore.h (struct core_fns) <core_read_registers>: Change
	core_reg_sect type to gdb_byte *.
	* arm-nbsd-nat.c (fetch_elfcore_registers): Likewise.
	* cris-tdep.c (fetch_core_registers): Likewise.
	* corelow.c (core_target::get_core_register_section): Change
	type of `contents` to gdb::byte_vector.
2020-01-13 18:12:08 -05:00
Andrew Burgess 9a6d629ccf gdb/tui: Place window titles in the center of the border
In tui-wingeneral.c:box_win () a comment suggest we should display
titles like this:

  +-WINDOW TITLE GOES HERE-+

However, we actually display them like this:

  +--WINDOW TITLE GOES HERE+

The former seems nicer to me, so that's what this commit does.  Short
titles will appear as:

  +-SHORT TITLE------------+

We previously didn't test the horizontal windows borders in the test
suite, however, I've updated things so that we do now check for the
'+-' and '-+' on the upper border, this will give us some protection.

gdb/ChangeLog:

	* tui/tui-wingeneral.c (box_win): Position the title in the center
	of the border.

gdb/testsuite/ChangeLog:

	* lib/tuiterm.exp (Term::_check_box): Check some parts of the top
	border.

Change-Id: Iead6910e3b4e68bdf6871f861f23d2efd699faf0
2020-01-13 22:56:48 +00:00
Simon Marchi d8b2f9e333 gdb: use std::vector instead of alloca in core_target::get_core_register_section
As I was trying to compile gdb for an m68k host, I got this error:

  CXX    corelow.o
In file included from /binutils-gdb/gdb/gdbsupport/common-defs.h:120,
                 from /binutils-gdb/gdb/defs.h:28,
                 from /binutils-gdb/gdb/corelow.c:20:
/binutils-gdb/gdb/corelow.c: In member function 'void core_target::get_core_register_section(regcache*, const regset*, const char*, int, int, const char*, bool)':
/binutils-gdb/gdb/../include/libiberty.h:727:36: error: 'alloca' bound is unknown [-Werror=alloca-larger-than=]
  727 | # define alloca(x) __builtin_alloca(x)
      |                    ~~~~~~~~~~~~~~~~^~~
/binutils-gdb/gdb/corelow.c:625:23: note: in expansion of macro 'alloca'
  625 |   contents = (char *) alloca (size);
      |                       ^~~~~~

We are using alloca to hold the contents of a the core register
sections.  These sections are typically fairly small, but there is no
realy guarantee, so I think it would be more reasonable to just use
dynamic allocation here.

gdb/ChangeLog:

	* corelow.c (core_target::get_core_register_section): Use
	  std::vector instead of alloca.
2020-01-13 14:33:19 -05:00
Simon Marchi c0bd321d77 gdbserver: remove rule for files from regformats/i386
The dat files in regformats/i386 were removed a while ago, this rule is
no longer necessary.

gdb/gdbserver/ChangeLog:

	* Makefile.in (%-generated.c): Remove rule for files from
	regformats/i386.
2020-01-13 14:19:05 -05:00
Simon Marchi bb564c588d Enable -Wmissing-declarations diagnostic
Now that most warnings of this kind are fixed, we can enable
-Wmissing-declarations.  I say "most", because it is likely that there
are some more in some configurations I am not able to build, but they
should be pretty easy to fix.

gdb/ChangeLog:

	* warning.m4: Add -Wmissing-declarations to build_warnings.
	* configure: Re-generate.

gdb/gdbserver/ChangeLog:

	* configure: Re-generate.

Change-Id: Iae9b59f22eb5dd1965d09f34c5c9e212cddf67ba
2020-01-13 14:06:09 -05:00
Simon Marchi 6e37c371af gdbserver: set IP_AGENT_EXPORT_FUNC to static when not building IPA, add declarations
Fixing the -Wmissing-declarations errors in gdbserver's tracepoint.c is
a bit tricky, because some functions are compiled for both gdbserver, in
which case they should be static, since they are only used in that file,
and for libinproctrace.so, in which case they should be externally
visible, since they need to be looked up.  In the case where they are
externally visible, -Wmissing-declarations requires that a declaration
exists (that's the point of the warning).

I've reused the IP_AGENT_EXPORT_FUNC macro to mark the functions as
static when compiled for gdbserver.  Some seemingly unnecessary
declarations are added for when compiling libinproctrace.so (thanks to
Tom for the suggestion).

gdb/gdbserver/ChangeLog:

	* tracepoint.h (IP_AGENT_EXPORT_FUNC) [!IN_PROCESS_AGENT]:
	Define to static.
	* tracepoint.c (stop_tracing, flush_trace_buffer,
	about_to_request_buffer_space, get_trace_state_variable_value,
	set_trace_state_variable_value, gdb_collect): Add declaration.

Change-Id: If9c66151bd00c3b9c5caa27a7c21c5a3a952de2a
2020-01-13 14:05:32 -05:00
Simon Marchi df4a0200dc gdbserver: make some functions static in linux-x86-low.c
These functions are only used in this file, so should be static.

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (x86_linux_regs_info, amd64_emit_eq_goto,
	amd64_emit_ne_goto, amd64_emit_lt_goto, amd64_emit_le_goto,
	amd64_emit_gt_goto, amd64_emit_ge_goto, amd64_emit_ge_goto,
	i386_emit_eq_goto, i386_emit_ne_goto, i386_emit_lt_goto,
	i386_emit_le_goto, i386_emit_gt_goto, i386_emit_ge_goto): Make
	static.

Change-Id: I703da41867735aefadd49140e80cd60f6ab9ad39
2020-01-13 14:04:53 -05:00
Simon Marchi 89e94ec9af gdbserver: include gdbsupport/common-inferior.h in inferiors.c
So that the definitions of get_inferior_cwd/set_inferior_cwd see their
declarations.

      CXX    inferiors.o
    /home/smarchi/src/binutils-gdb/gdb/gdbserver/inferiors.c: In function ‘const char* get_inferior_cwd()’:
    /home/smarchi/src/binutils-gdb/gdb/gdbserver/inferiors.c:228:1: error: no previous declaration for ‘const char* get_inferior_cwd()’ [-Werror=missing-declarations]
     get_inferior_cwd ()
     ^~~~~~~~~~~~~~~~
    /home/smarchi/src/binutils-gdb/gdb/gdbserver/inferiors.c: In function ‘void set_inferior_cwd(const char*)’:
    /home/smarchi/src/binutils-gdb/gdb/gdbserver/inferiors.c:236:1: error: no previous declaration for ‘void set_inferior_cwd(const char*)’ [-Werror=missing-declarations]
     set_inferior_cwd (const char *cwd)
     ^~~~~~~~~~~~~~~~

gdb/gdbserver/ChangeLog:

	* inferiors.c: Include gdbsupport/common-inferior.h.

Change-Id: Iae5ccb3e1dc37ce79f03f08465f603a0411e7af0
2020-01-13 14:03:18 -05:00
Simon Marchi 2552728af8 gdbserver: include hostio.h in hostio-errno.c
... so that the definition of hostio_last_error_from_errno in hostio-errno.c
sees the declaration in hostio.h.

Fix this error:

      CXX    hostio-errno.o
    /home/smarchi/src/binutils-gdb/gdb/gdbserver/hostio-errno.c: In function ‘void hostio_last_error_from_errno(char*)’:
    /home/smarchi/src/binutils-gdb/gdb/gdbserver/hostio-errno.c:28:1: error: no previous declaration for ‘void hostio_last_error_from_errno(char*)’ [-Werror=missing-declarations]
     hostio_last_error_from_errno (char *buf)
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

gdb/gdbserver/ChangeLog:

	* hostio-errno.c: Include hostio.h.

Change-Id: I056308fd4ce12810d0a1b826c423bd0c7eeb8944
2020-01-13 14:03:13 -05:00
Simon Marchi 6b3661116e gdb: add declaration to Python init function
When I try to enable -Wmissing-declarations, I get this error:

      CXX    python/python.o
    /home/smarchi/src/binutils-gdb/gdb/python/python.c: In function ‘PyObject* init__gdb_module()’:
    /home/smarchi/src/binutils-gdb/gdb/python/python.c:1582:1: error: no previous declaration for ‘PyObject* init__gdb_module()’ [-Werror=missing-declarations]
     init__gdb_module (void)
     ^~~~~~~~~~~~~~~~

Prevent it by providing a declaration just before the definition.

gdb/ChangeLog:

	* python/python.c (init__gdb_module): Add declaration.

Change-Id: I394bc691b7db624708cc4cb2cda28a56ab85a82b
2020-01-13 14:03:04 -05:00