aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2020-01-21gdb: add declaration for _initialize_gdbarch in gdbarch.shSimon Marchi2-1/+6
In commit gdb: add back declarations for _initialize functions 6c2659886f7018fcca26ee0fc813bc9748fb8513 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-21gdb: remove uses of iterate_over_inferiors in remote-sim.cSimon Marchi2-50/+38
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-21gdb: fix indentation in infrun.cSimon Marchi2-37/+41
I noticed the indentation there was off, this patch fixes it. gdb/ChangeLog: * infrun.c (proceed): Fix indentation.
2020-01-21Allow use of Pygments to colorize source codeTom Tromey8-4/+150
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-21Convert an int flag variable to boolLuis Machado2-4/+12
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-21Add more debugging output to aarch64_displaced_step_fixupLuis Machado2-2/+30
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-21Fix step-over-syscall.exp failureLuis Machado2-4/+20
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-19sim: don't rely on inferior_ptid in gdbsim_target::waitSimon Marchi1-1/+1
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-19Call disassemble_free_target in gdbTom Tromey3-1/+19
Commit 20135676fc4c3912297c313b3e0d3cbd6cc402e3 ("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-19Replace init_cutu_and_read_dies with a classTom Tromey2-323/+267
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-19Remove flickering from the TUITom Tromey9-5/+116
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-19Make "file" clear TUI source windowTom Tromey4-5/+22
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-19gdb/linux-fork: simplify one_fork_pSimon Marchi2-2/+5
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-17gdb: remove uses of iterate_over_inferiors in top.cSimon Marchi2-32/+28
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-17gdb: remove uses of iterate_over_inferiors in mi/mi-main.cSimon Marchi2-46/+40
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-17gdb: remove use of iterate_over_inferiors in mi/mi-interp.cSimon Marchi2-28/+26
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-17gdb: remove use of iterate_over_inferiors in py-inferior.cSimon Marchi2-14/+15
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-16Fix some spelling errors.Christian Biesinger8-7/+20
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-16Add type for $_tlb->process_environment_block->process_parametersHannes Domani2-1/+65
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-16Ensure proc-service symbols have default visibility (PR build/24805)Pedro Alves1-0/+11
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[gdb] Move ChangeLog entries to their right filesPedro Alves29-314/+453
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-16Support for DWARF5 location lists entriesNitika Achra2-0/+44
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-15Use get_thread_regcache instead of get_current_regcache in post_create_inferiorSimon Marchi2-1/+7
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-14Fix valgrind error from gdb.decode_lineTom Tromey4-0/+25
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-14Don't link gdb twice against libibertyTom Tromey2-1/+5
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-14Remove use of <config.h> from gdb/nat/Tom Tromey4-24/+6
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-14Move many configure checks to common.m4Tom Tromey8-1974/+3232
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-14Move gdbsupport to the top levelTom Tromey130-15301/+135
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-14Consolidate definition of USE_WIN32APITom Tromey7-37/+55
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-14Fix indentation in common.m4Tom Tromey5-16/+25
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-14Make skip without argument skip the current inline functionBernd Edlinger4-10/+30
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-14Fix/Update misc commentsLuis Machado5-15/+24
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-13gdb: Handle malformed ELF, symbols in non-allocatable sectionsAndrew Burgess6-4/+253
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-13gdb/testsuite: Allow DWARF assembler to create multiple line tablesAndrew Burgess2-0/+7
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-13Dwarf 5: Handle debug_str_offsets and indexed attributes that have base offsets.Ali Tamur5-92/+282
* 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-13gdb: use gdb::byte_vector instead of std::vector<char> in ↵Simon Marchi5-4/+13
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-13gdb/tui: Place window titles in the center of the borderAndrew Burgess4-5/+26
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-13gdb: use std::vector instead of alloca in core_target::get_core_register_sectionSimon Marchi2-6/+10
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-13gdbserver: remove rule for files from regformats/i386Simon Marchi2-3/+5
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-13Enable -Wmissing-declarations diagnosticSimon Marchi5-3/+15
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-13gdbserver: set IP_AGENT_EXPORT_FUNC to static when not building IPA, add ↵Simon Marchi3-1/+29
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-13gdbserver: make some functions static in linux-x86-low.cSimon Marchi2-13/+22
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-13gdbserver: include gdbsupport/common-inferior.h in inferiors.cSimon Marchi2-0/+5
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-13gdbserver: include hostio.h in hostio-errno.cSimon Marchi2-0/+7
... 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-13gdb: add declaration to Python init functionSimon Marchi2-0/+5
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-13gdb: add back declarations for _initialize functionsSimon Marchi400-354/+1167
I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13gdb: make regformats output a declaration for the init functionSimon Marchi2-0/+8
When compiling gdbserver for an architecture that uses the regdat.sh script (such as m68k) and the -Wmissing-declarations compiler flag, I get: REGDAT reg-m68k-generated.c CXX reg-m68k.o reg-m68k-generated.c:30:1: error: no previous declaration for 'void init_registers_m68k()' [-Werror=missing-declarations] 30 | init_registers_m68k (void) | ^~~~~~~~~~~~~~~~~~~ The same happens with other architectures, such as s390, but I'll be using 68k as an example. The init_registers_m68k function is defined in reg-m68k-generated.c, which is produced by the regformats/regdat.sh script. This script reads the regformats/reg-m68k.dat file, containing a register description, and produces C code that creates a corresponding target description at runtime. The init_registers_m68k function is invoked at initialization time in linux-m68k-low.c. The function must therefore be non-static, but does not have a declaration at the moment. The real clean way of fixing this would be to make regdat.sh generate a .h file (in addition to the .c file) with declarations for whatever is in the .c file. The generated .c file would include the .h file, and therefore the definition would have a corresponding declaration. The linux-m68k-low.c file would also include this .h file, instead of having its own declaration of init_registers_m68k, like it does now. However, this would be a quite big change for not much gain. As far as I understand, some common architectures (i386, x86-64, ARM, AArch64) have been moved to dynamically building target descriptions based on features (the linux-*-tdesc.c files in gdbserver) and don't use regdat.sh anymore. Logically (and given infinite development resources), the other architectures would be migrated to this system too and the regdat.sh script would be dropped. A new architecture would probably not use regdat.sh either. So I therefore propose this simpler patch instead, which just adds a local declaration in the generated file. gdb/ChangeLog: * regformats/regdat.sh: Generate declaration for init function.
2020-01-13gdbserver: fix Makefile dependency of regformat-generated files on regdat.shSimon Marchi2-4/+9
The intent of the rules modified by this patch is that the *-generated.c files generated by regdat.sh are re-generated in the event that regdat.sh is modified. However, if I build, touch regdat.sh, and build again, the files are not re-generated during the second build. This is because regdat.sh is specified as an order-only dependency [1], after the pipe. Make therefore only ensures that regdat.sh exists before generating the target file, it doesn't check the timestamp of regdat.sh. This patch changes it to be a regular prerequisite. The rules use the $< variable, which is substituted by the first prerequisite only, so the command lines won't change. [1] https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html gdb/gdbserver/ChangeLog: * Makefile.in (%-generated.c): Make $(regdat_sh) a regular prerequisite.
2020-01-13gdb: adjust remote-sim.c to multi-targetSimon Marchi2-78/+91
The remote-sim.c file doesn't build since the main multi-target patch (5b6d1e4f, "Multi-target support"), this patch is an attempt to fix it. I have only build-tested it, so I'm not sure it runs fine, but it should get us close at least. I made these functions methods of the gdbsim_target, because they need to pass the target down to some GDB core functions, like find_inferior_ptid: - get_sim_inferior_data_by_ptid (renamed to get_inferior_data_by_ptid) - gdbsim_resume_inferior (renamed to resume_one_inferior) - gdbsim_close_inferior (renamed to close_one_inferior) In the last two, I changed iterate_over_inferiors to a range-based for, since that gives simpler code (no need to pass data through the void pointer). The next_pid variable, INITIAL_PID macro and sim_inferior_data structure are simply moved up in the file, above gdbsim_target. gdb/ChangeLog: * remote-sim.c (next_pid, INITIAL_PID, sim_inferior_data): Move up. (gdbsim_target) <get_inferior_data_by_ptid, resume_one_inferior, close_one_inferior>: New methods. (get_sim_inferior_data_by_ptid): Move to gdbsim_target, pass down target to find_inferior_pid. (gdbsim_target::fetch_registers, gdbsim_target::store_registers): Pass down target to find_inferior_ptid. (gdbsim_target::create_inferior): Pass down target to add_thread_silent. (gdbsim_close_inferior): Move to gdbsim_close_inferior, pass target down to find_inferior_ptid and switch_to_thread. (gdbsim_target::close): Update to call close_one_inferior. (struct resume_data): Remove. (gdbsim_resume_inferior): Move to gdbsim_target. Take arguments directly, rather than through a void pointer. (gdbsim_target::resume): Update to call resume_one_inferior.
2020-01-12gdb: include gdb_wait.h in gdb_wait.cSimon Marchi2-0/+6
When building for mingw with -Wmissing-declarations, I get: CXX gdbsupport/gdb_wait.o /binutils-gdb/gdb/gdbsupport/gdb_wait.c:52:1: error: no previous declaration for 'int windows_status_to_termsig(long unsigned int)' [-Wer ror=missing-declarations] 52 | windows_status_to_termsig (unsigned long status) | ^~~~~~~~~~~~~~~~~~~~~~~~~ Make gdb_wait.c include gdb_wait.h to fix it. gdb/ChangeLog: * gdbsupport/gdb_wait.c: Include gdb_wait.h.