aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
AgeCommit message (Collapse)AuthorFilesLines
2021-11-09Fix build on rhES5Tom Tromey2-0/+20
The rhES5 build failed due to an upstream import a while back. The bug here is that, while the 'personality' function exists, ADDR_NO_RANDOMIZE is only defined in <linux/personality.h>, not <sys/personality.h>. However, <linux/personality.h> does not declare the 'personality' function, and <sys/personality.h> and <linux/personality.h> cannot both be included. This patch restores one of the removed configure checks and updates the code to check it. We had this as a local patch at AdaCore, because it seemed like there was no interest upstream. However, now it turns out that this fixes PR build/28555, so I'm sending it now.
2021-11-04gdbserver: re-generate configureSimon Marchi2-0/+49
I get some diffs when running autoconf in gdbserver, probably leftovers from commit 5dfe4bfcb969 ("Fix format_pieces selftest on Windows"). Re-generate configure in that directory. Change-Id: Icdc9906af95fbaf1047a579914b2983f8ec5db08
2021-11-03[AArch64] Make gdbserver register set selection dynamicLuis Machado1-85/+101
The current register set selection mechanism for AArch64 is static, based on a pre-populated array of register sets. This means that we might potentially probe register sets that are not available. This is OK if the kernel errors out during ptrace, but probing the tag_ctl register, for example, does not result in a ptrace error if the kernel supports the tagged address ABI but not MTE (PR 28355). Making the register set selection dynamic, based on feature checks, solves this and simplifies the code a bit. It allows us to list all of the register sets only once, and pick and choose based on HWCAP/HWCAP2 or other properties. I plan to backport this fix to GDB 11 as well. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28355
2021-10-29gdb: or1k: implement gdb serverStafford Horne3-0/+275
This patch adds gdbserver support for OpenRISC. This has been used for debugging the glibc port that in being worked on here: https://github.com/openrisc/or1k-glibc/tree/or1k-port-2 Hence the comment about registers definitions being inline with glibc.
2021-10-25gdbserver: make target_pid_to_str return std::stringSimon Marchi6-51/+50
I wanted to write a warning that included two target_pid_to_str calls, like this: warning (_("Blabla %s, blabla %s"), target_pid_to_str (ptid1), target_pid_to_str (ptid2)); This doesn't work, because target_pid_to_str stores its result in a static buffer, so my message would show twice the same ptid. Change target_pid_to_str to return an std::string to avoid this. I don't think we save much by using a static buffer, but it is more error-prone. Change-Id: Ie3f649627686b84930529cc5c7c691ccf5d36dc2
2021-10-22Fix 'uninstall' targetTom Tromey1-1/+4
This adds some missing code to the 'uninstall' targets in gdb and gdbserver. It also changes gdb's uninstall target so that it no longer tries to remove any man page -- this is already done (and more correctly) by doc/Makefile.in. I tested this with 'make install' followed by 'make uninstall', then examining the install tree for regular files. Only the 'dir' file remains, but this appears to just be how 'install-info' is intended to work.
2021-10-22Remove unused variables from gdbserver's MakefileTom Tromey1-26/+1
This removes a number of unused variables from gdbserver's Makefile. I found these while working on the subsequent patches, and figured it would be cleaner to have a separate patch for the deletions.
2021-10-21gdb, gdbserver: make target_waitstatus safeSimon Marchi8-208/+171
I stumbled on a bug caused by the fact that a code path read target_waitstatus::value::sig (expecting it to contain a gdb_signal value) while target_waitstatus::kind was TARGET_WAITKIND_FORKED. This meant that the active union field was in fact target_waitstatus::value::related_pid, and contained a ptid. The read signal value was therefore garbage, and that caused GDB to crash soon after. Or, since that GDB was built with ubsan, this nice error message: /home/simark/src/binutils-gdb/gdb/linux-nat.c:1271:12: runtime error: load of value 2686365, which is not a valid value for type 'gdb_signal' Despite being a large-ish change, I think it would be nice to make target_waitstatus safe against that kind of bug. As already done elsewhere (e.g. dynamic_prop), validate that the type of value read from the union matches what is supposed to be the active field. - Make the kind and value of target_waitstatus private. - Make the kind initialized to TARGET_WAITKIND_IGNORE on target_waitstatus construction. This is what most users appear to do explicitly. - Add setters, one for each kind. Each setter takes as a parameter the data associated to that kind, if any. This makes it impossible to forget to attach the associated data. - Add getters, one for each associated data type. Each getter validates that the data type fetched by the user matches the wait status kind. - Change "integer" to "exit_status", "related_pid" to "child_ptid", just because that's more precise terminology. - Fix all users. That last point is semi-mechanical. There are a lot of obvious changes, but some less obvious ones. For example, it's not possible to set the kind at some point and the associated data later, as some users did. But in any case, the intent of the code should not change in this patch. This was tested on x86-64 Linux (unix, native-gdbserver and native-extended-gdbserver boards). It was built-tested on x86-64 FreeBSD, NetBSD, MinGW and macOS. The rest of the changes to native files was done as a best effort. If I forgot any place to update in these files, it should be easy to fix (unless the change happens to reveal an actual bug). Change-Id: I0ae967df1ff6e28de78abbe3ac9b4b2ff4ad03b7
2021-10-21gdbserver: initialize the members of lwp_info in-classSimon Marchi2-29/+31
Add a constructor to initialize the waitstatus members. Initialize the others in the class directly. Change-Id: I10f885eb33adfae86e3c97b1e135335b540d7442
2021-10-21gdbserver: make thread_info non-PODSimon Marchi2-14/+18
Add a constructor and a destructor. The constructor takes care of the initialization that happened in add_thread, while the destructor takes care of the freeing that happened in free_one_thread. This is needed to make target_waitstatus non-POD, as thread_info contains a member of that type. Change-Id: I1db321b4de9dd233ede0d5c101950f1d6f1d13b7
2021-10-04[gdb/build] Add CXX_DIALECT to CXXTom de Vries1-0/+8
Say we use a gcc version that (while supporting c++11) does not support c++11 by default, and needs an -std setting to enable it. If gdb would use the default AX_CXX_COMPILE_STDCXX from autoconf-archive, then we'd have: ... CXX="g++ -std=gnu++11" ... That mechanism however has the following problem (quoting from commit 0bcda685399): ... the top level Makefile passes CXX down to subdirs, and that overrides whatever gdb/Makefile may set CXX to. The result would be that a make invocation from the build/gdb/ directory would use "g++ -std=gnu++11" as expected, while a make invocation at the top level would not. ... Commit 0bcda685399 fixes this by using a custom AX_CXX_COMPILE_STDCXX which does: ... CXX=g++ CXX_DIALECT=-std=gnu++11 ... The problem reported in PR28318 is that using the custom instead of the default AX_CXX_COMPILE_STDCXX makes the configure test for std::thread support fail. We could simply add $CXX_DIALECT to the test for std::thread support, but that would have to be repeated for each added c++ support test. Instead, fix this by doing: ... CXX="g++ -std=gnu++11" CXX_DIALECT=-std=gnu++11 ... This is somewhat awkward, since it results in -std=gnu++11 occuring twice in some situations: ... $ touch src/gdb/dwarf2/read.c $ ( cd build/gdb; make V=1 dwarf2/read.o ) g++-4.8 -std=gnu++11 -x c++ -std=gnu++11 ... ... However, both settings are needed: - the switch in CXX for the std::thread tests (and other tests) - the switch in CXX_DIALECT so it can be appended in Makefiles, to counteract the fact that the top-level Makefile overrides CXX The code added in gdb/ax_cxx_compile_stdcxx.m4 is copied from the default AX_CXX_COMPILE_STDCXX from autoconf-archive. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28318
2021-09-23Change ptid_t::tid to ULONGESTTom Tromey1-2/+2
The ptid_t 'tid' member is normally used as an address in gdb -- both bsd-uthread and ravenscar-thread use it this way. However, because the type is 'long', this can cause problems with sign extension. This patch changes the type to ULONGEST to ensure that sign extension does not occur.
2021-09-23Remove defaulted 'tid' parameter to ptid_t constructorTom Tromey3-9/+9
I wanted to find, and potentially modify, all the spots where the 'tid' parameter to the ptid_t constructor was used. So, I temporarily removed this parameter and then rebuilt. In order to make it simpler to search through the "real" (nonzero) uses of this parameter, something I knew I'd have to do multiple times, I removed any ", 0" from constructor calls. Co-Authored-By: John Baldwin <jhb@FreeBSD.org>
2021-09-07Remove unused declaration from gdbserver/win32-low.hTom Tromey1-3/+0
I noticed that gdbserver/win32-low.h has an unused declaration. This code was changed a while ago, but this declaration slipped through. This patch removes it. Tested by rebuilding.
2021-08-17gdbserver: Check r_version < 1 for Linux debugger interfaceH.J. Lu1-1/+1
Update gdbserver to check r_version < 1 instead of r_version != 1 so that r_version can be bumped for a new field in the glibc debugger interface to support multiple namespaces. Since so far, the gdbserver only reads fields defined for r_version == 1, it is compatible with r_version >= 1. All future glibc debugger interface changes will be backward compatible. If there is ever the need for backward incompatible change to the glibc debugger interface, a new DT_XXX element will be provided to access the new incompatible interface. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11839
2021-07-26Fix the Windows buildTom Tromey1-3/+3
The gdb build was broken on Windows after the patch to change get_inferior_cwd. This patch fixes the build.
2021-07-26gdb: move remaining ChangeLogs to legacy filesAndrew Burgess1-0/+0
In commit: commit f069ea46a03ae868581d1c852da28e979ea1245a Date: Sat Jul 3 16:29:08 2021 -0700 Rename gdb/ChangeLog to gdb/ChangeLog-2021 The gdb/ChangeLog file was renamed, but all of the other ChangeLog files relating to gdb were left in place. As I understand things, the no ChangeLogs policy applies to all the GDB related directories, so this commit renames all of the remaining GDB related ChangeLog files. As with the original commit, the intention behind this commit is to hopefully stop people merging ChangeLog entries by mistake. The renames carried out in this commit are: gdb/doc/ChangeLog -> gdb/doc/ChangeLog-1991-2021 gdb/stubs/ChangeLog -> gdb/stubs/ChangeLog-2012-2020 gdb/testsuite/ChangeLog -> gdb/testsuite/ChangeLog-2014-2021 gdbserver/ChangeLog -> gdbserver/ChangeLog-2002-2021 gdbsupport/ChangeLog -> gdbsupport/ChangeLog-2020-2021
2021-07-23gdb: make inferior::m_cwd an std::stringSimon Marchi3-14/+12
Same idea as the previous patch, but for m_cwd. To keep things consistent across the board, change get_inferior_cwd as well, which is shared with GDBserver. So update the related GDBserver code too. Change-Id: Ia2c047fda738d45f3d18bc999eb67ceb8400ce4e
2021-07-23gdb: un-share set_inferior_cwd declarationSimon Marchi2-1/+5
The declaration of set_inferior_cwd is currently shared between gdb and gdbserver, in gdbsupport/common-inferior.h. It doesn't need to be, as set_inferior_cwd is not called from common code. Only get_inferior_cwd needs to. The motivation for this is that a future patch will change the prototype of set_inferior_cwd in gdb, and I don't want to change it for gdbserver unnecessarily. I see this as a good cleanup in any case, to reduce to just the essential what is shared between GDB and GDBserver. Change-Id: I3127d27d078f0503ebf5ccc6fddf14f212426a73
2021-07-05gdbsupport/common.m4: check for sigtimedwaitSimon Marchi2-1/+4
The next patch will make the use of sigtimedwait conditional to whether the platform provides it. Start by adding a configure check for it. gdbsupport/ChangeLog: * common.m4 (GDB_AC_COMMON): Check for sigtimedwait. * config.in, configure: Re-generate. gdb/ChangeLog: * config.in, configure: Re-generate. gdbserver/ChangeLog: * config.in, configure: Re-generate. Change-Id: Ic7613fe14521b966b4d991bbcd0933ab14629c05
2021-06-19gdb/gdbserver: switch to AC_CONFIG_MACRO_DIRSMike Frysinger5-19/+24
These dirs don't use automake, so use AC_CONFIG_MACRO_DIRS to specify ../config as a search dir for m4 macros. This allows removal of a lot of hand-written m4_include's from acinclude.m4 files, and simplifies use of `aclocal` or `autoreconf` as manual -I is not needed.
2021-06-14gnulib: define the path to gnulib's parent dirMike Frysinger2-4/+8
The current setting assumes that gnulib is only used by dirs immediately under the source root. Trying to build it two or more levels deep fails. Switch GNULIB_BUILDDIR to a relative GNULIB_PARENT_DIR so that it can be used to construct both the build & source paths.
2021-05-27gdb: fix some indentation issuesSimon Marchi2-21/+19
I wrote a small script to spot a pattern of indentation mistakes I saw happened in breakpoint.c. And while at it I ran it on all files and fixed what I found. No behavior changes intended, just indentation and addition / removal of curly braces. gdb/ChangeLog: * Fix some indentation mistakes throughout. gdbserver/ChangeLog: * Fix some indentation mistakes throughout. Change-Id: Ia01990c26c38e83a243d8f33da1d494f16315c6e
2021-05-17gdb: additional settings for emacs in .dir-locals.elAndrew Burgess2-1/+9
Two additional settings for developers who use emacs: 1. Set brace-list-open to 0 for C and C++ modes, this ensures we format things like: enum blah { .... }; Instead of the default for the emacs GNU style: enum blah { ... }; The former seems to be the GDB style. 2. Set sentence-end-double-space to t. This is actually the default value for this setting, but if anyone has customised this to nil in general, then forcing this back to t for GDB files will give a better behaviour for the paragraph filling. gdb/ChangeLog: * .dir-locals.el: Set sentence-end-double-space for all modes, and set brace-list-open to 0 for C and C++ modes. gdbserver/ChangeLog: * .dir-locals.el: Set sentence-end-double-space for all modes, and set brace-list-open to 0 for C and C++ modes. gdbsupport/ChangeLog: * .dir-locals.el: Set sentence-end-double-space for all modes, and set brace-list-open to 0 for C and C++ modes.
2021-05-08gdb, gdbserver: make status_to_str return std::stringSimon Marchi2-1/+6
Instead of using a static buffer. This is safer, and we don't really mind about any extra dynamic allocation here, since it's only used for debug purposes. gdb/ChangeLog: * nat/linux-waitpid.c (status_to_str): Return std::string. * nat/linux-waitpid.h (status_to_str): Likewise. * linux-nat.c (linux_nat_post_attach_wait): Adjust. (linux_nat_target::attach): Adjust. (linux_handle_extended_wait): Adjust. (wait_lwp): Adjust. (stop_wait_callback): Adjust. (linux_nat_filter_event): Adjust. (linux_nat_wait_1): Adjust. * nat/linux-waitpid.c (status_to_str): Adjust. * nat/linux-waitpid.h (status_to_str): Adjust. gdbserver/ChangeLog: * linux-low.cc (linux_process_target::wait_for_event_filtered): Adjust to status_to_str returning std::string. Change-Id: Ia8aead70270438a5690f243e6faafff6c38ff757
2021-05-08Don't run personality syscall at configure time; don't check it at allPedro Alves4-85/+7
Currently, in order to tell whether support for disabling address space randomization on Linux is available, GDB checks if the personality syscall works, at configure time. I.e., it does a run test, instead of a compile/link test: AC_RUN_IFELSE([PERSONALITY_TEST], [have_personality=true], [have_personality=false], This is a bit bogus, because the machine the build is done on may not (and is when you consider distro gdbs) be the machine that eventually runs gdb. It would be better if this were a compile/link test instead, and then at runtime, GDB coped with the personality syscall failing. Actually, GDB already copes. One environment where this is problematic is building GDB in a Docker container -- by default, Docker runs the container with seccomp, with a profile that disables the personality syscall. You can tell Docker to use a less restricted seccomp profile, but I think we should just fix it in GDB. "man 2 personality" says: This system call first appeared in Linux 1.1.20 (and thus first in a stable kernel release with Linux 1.2.0); library support was added in glibc 2.3. ... ADDR_NO_RANDOMIZE (since Linux 2.6.12) With this flag set, disable address-space-layout randomization. glibc 2.3 was released in 2002. Linux 2.6.12 was released in 2005. The original patch that added the configure checks was submitted in 2008. The first version of the patch that was submitted to the list called personality from common code: https://sourceware.org/pipermail/gdb-patches/2008-June/058204.html and then was moved to Linux-specific code: https://sourceware.org/pipermail/gdb-patches/2008-June/058209.html Since HAVE_PERSONALITY is only checked in Linux code, and ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely removing the configure checks. If for some odd reason, some remotely modern system still needs a configure check, then we can revert this commit but drop the AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE cross-compile fallback. gdb/ChangeLog: * linux-nat.c (linux_nat_target::supports_disable_randomization): Remove references to HAVE_PERSONALITY. * nat/linux-personality.c: Remove references to HAVE_PERSONALITY. (maybe_disable_address_space_randomization) (~maybe_disable_address_space_randomizatio): Remove references to HAVE_PERSONALITY. * config.in, configure: Regenerate. gdbserver/ChangeLog: * linux-low.cc: (linux_process_target::supports_disable_randomization): Remove reference to HAVE_PERSONALITY. * config.in, configure: Regenerate. gdbsupport/ChangeLog: * common.m4 (personality test): Remove.
2021-05-08Don't include sys/personality.h in linux-low.cc anymorePedro Alves2-7/+5
Lancelot pointed out that since the refactor at: https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html the sys/personality.h include is not needed in linux-low.cc anymore, as it does not call personality directly itself anymore. gdbserver/ChangeLog: * linux-low.cc: Don't include sys/personality.h or define ADDR_NO_RANDOMIZE.
2021-05-06gdbserver/server: make some functions voidTankut Baris Aktemur2-24/+16
The 'handle_v_attach', 'handle_v_run', and 'handle_v_kill' functions' return values are unused. They indicate error/success result by putting packets. Make the functions void. Tested by rebuilding. gdbserver/ChangeLog: 2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * server.cc (handle_v_attach) (handle_v_run) (handle_v_kill): Make void.
2021-05-03Fix x86_64 mingw buildTom Tromey2-1/+7
PR build/27807 points out that my recent changes to the Windows port missed a spot in win32-i386-low.cc -- a call to win32_Wow64GetThreadContext remained, causing link errors in gdbserver. This happened because I tested an i686 build, but this code is only used on an x86_64 build. This patch fixes the bug. I am checking it in. gdbserver/ChangeLog 2021-05-03 Tom Tromey <tromey@adacore.com> PR build/27807: * win32-i386-low.cc (i386_get_thread_context): Call Wow64GetThreadContext, not win32_Wow64GetThreadContext.
2021-04-30Share DLL code between gdb and gdbserverTom Tromey2-162/+17
This moves the new DLL-loading code into nat/windows-nat.c, and changes both gdb and gdbserver to use the shared code. One client-provided callback, handle_load_dll, is changed to allow the code to be shared. This callback was actually never called from nat/windows-nat.c; maybe I had planned to share more here and then didn't finish... I'm not sure. gdb/ChangeLog 2021-04-30 Tom Tromey <tromey@adacore.com> * windows-nat.c (windows_nat::handle_load_dll): Update. (windows_nat_target::get_windows_debug_event): Call dll_loaded_event. (windows_add_all_dlls, windows_add_dll): Move to nat/windows-nat.c. * nat/windows-nat.h (handle_load_dll): Change parameters. (dll_loaded_event, windows_add_all_dlls): Declare. * nat/windows-nat.c (windows_add_dll, windows_add_all_dlls): Move from windows-nat.c. (dll_loaded_event): New function. gdbserver/ChangeLog 2021-04-30 Tom Tromey <tromey@adacore.com> * win32-low.cc (do_initial_child_stuff): Update. (windows_nat::handle_load_dll): Rename from win32_add_one_solib. Change parameter type. (win32_add_dll, win32_add_all_dlls) (windows_nat::handle_load_dll): Remove. (get_child_debug_event): Call dll_loaded_event.
2021-04-30Use nat/windows-nat function indirection codeTom Tromey2-142/+58
This changes gdbserver to use the function indirection code that was just moved into nat/windows-nat.[ch]. One additional function is used by gdbserver that was not used by gdb. gdb/ChangeLog 2021-04-30 Tom Tromey <tromey@adacore.com> * nat/windows-nat.h (GenerateConsoleCtrlEvent): New define. (GenerateConsoleCtrlEvent_ftype, GenerateConsoleCtrlEvent): Declare. * nat/windows-nat.c (GenerateConsoleCtrlEvent): Define. (initialize_loadable): Initialize GenerateConsoleCtrlEvent. gdbserver/ChangeLog 2021-04-30 Tom Tromey <tromey@adacore.com> * win32-low.cc (GETPROCADDRESS): Remove. (winapi_DebugActiveProcessStop, winapi_DebugSetProcessKillOnExit) (winapi_DebugBreakProcess, winapi_GenerateConsoleCtrlEvent) (winapi_Wow64SetThreadContext, win32_Wow64GetThreadContext) (win32_Wow64SetThreadContext): Remove. (win32_set_thread_context, do_initial_child_stuff) (win32_process_target::attach, win32_process_target::detach): Update. (winapi_EnumProcessModules, winapi_EnumProcessModulesEx) (winapi_GetModuleInformation, winapi_GetModuleInformationA): Remove. (win32_EnumProcessModules, win32_EnumProcessModulesEx) (win32_GetModuleInformation, win32_GetModuleInformationA): Remove. (load_psapi): Remove. (win32_add_dll, win32_process_target::request_interrupt): Update. (initialize_low): Call initialize_loadable.
2021-04-14Remove use of _WIN32_WCETom Tromey2-2/+5
This removes the one last use of _WIN32_WCE from gdbserver. gdbserver/ChangeLog 2021-04-14 Tom Tromey <tromey@adacore.com> * win32-low.cc (windows_nat::handle_load_dll): Don't check _WIN32_WCE.
2021-04-13Remove WinCE code from gdbreplayPedro Alves2-51/+4
gdbserver/ChangeLog: * gdbreplay.c [__MINGW32CE__] (COUNTOF, errno, strerror): Remove.
2021-04-13Remove some unused typedefs from gdbserverTom Tromey2-4/+5
I noticed that gdbserver/win32-low.cc has a few typedefs that are not used. This patch removes them. gdbserver/ChangeLog 2021-04-13 Tom Tromey <tromey@adacore.com> * win32-low.cc (winapi_CreateToolhelp32Snapshot) (winapi_Module32First, winapi_Module32Next): Remove typedefs.
2021-04-13Remove process_stratum_target::hostio_last_error abstractionPedro Alves10-61/+22
Now that the WinCE port is gone, all ports map host I/O errors from errno, so this abstraction is no longer necessary. Basically undoes: https://sourceware.org/pipermail/gdb-patches/2008-January/055511.html https://sourceware.org/pipermail/gdb-patches/attachments/20080131/f44e7012/attachment.bin gdbserver/ChangeLog: * Makefile.in (SFILES): Remove hostio-errno.cc. * configure: Regenerate. * configure.ac (GDBSERVER_DEPFILES): No longer add $srv_hostio_err_objs. * configure.srv (srv_hostio_err_objs): Delete. * hostio-errno.cc: Delete. * hostio.cc (hostio_error): Inline hostio_last_error_from_errno here. * hostio.h (hostio_last_error_from_errno): Delete. * target.cc (process_stratum_target::hostio_last_error): Delete. * target.h (class process_stratum_target) <hostio_last_error>: Delete.
2021-04-12gdb, gdbserver: remove WinCE support codeSimon Marchi3-175/+10
The support for WinCE was removed with commit 84b300de3666 ("gdbserver: remove support for ARM/WinCE"). There is some leftover code for WinCE support, guarded by the _WIN32_WCE macro, which I didn't know of at the time. I didn't remove the _WIN32_WCE references in the tests, because in theory we still support the WinCE architecture in GDB (when debugging remotely). So someone could run a test with that (although I'd be really surprised). gdb/ChangeLog: * nat/windows-nat.c: Remove all code guarded by _WIN32_WCE. * nat/windows-nat.h: Likewise. gdbserver/ChangeLog: * win32-low.cc: Remove all code guarded by _WIN32_WCE. * win32-low.h: Likewise. Change-Id: I7a871b897e2135dc195b10690bff2a01d9fac05a
2021-04-12gdbserver: constify the 'pid_to_exec_file' target opTankut Baris Aktemur8-9/+19
gdbserver/ChangeLog: 2021-04-12 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * target.h (class process_stratum_target) <pid_to_exec_file>: Constify the return type. Update the definition/references below. * target.cc (process_stratum_target::pid_to_exec_file) * linux-low.h (class linux_process_target) <pid_to_exec_file> * linux-low.cc (linux_process_target::pid_to_exec_file) * netbsd-low.h (class netbsd_process_target) <pid_to_exec_file> * netbsd-low.cc (netbsd_process_target::pid_to_exec_file) * server.cc (handle_qxfer_exec_file)
2021-04-11Improve support for loading DLLs at run time in gdbserver.Eli Zaretskii2-12/+52
This fixes win32-low.cc in the same way as a recent change in windows-nat.c did for GDB: if the lpImageName member of the load-DLL debug event doesn't allow us to find the file name of the DLL, then loop over all the DLLs mapped into the inferior to find the one loaded at the same base address as given by the lpBaseOfDll member of the debug event. gdbserver/ChangeLog: 2021-04-11 Eli Zaretskii <eliz@gnu.org> * win32-low.cc (win32_add_dll): New function, with body almost identical to what win32_add_all_dlls did. Accepts one argument; if that is non-NULL, returns the file name of the DLL that is loaded at the base address equal to that argument, or NULL if not found. If the argument is NULL, add all the DLLs loaded by the inferior to the list of solibs and return NULL. (win32_add_all_dlls): Now a thin wrapper around win32_add_dll. (windows_nat::handle_load_dll) [!_WIN32_WCE]: If get_image_name failed to glean the file name of the DLL, call win32_add_dll to try harder using the lpBaseOfDll member of the load-DLL event.
2021-03-30Fix inverted logic bugLuis Machado2-5/+10
During reviews, I changed the success/failure variables from int to bool, but missed updating the code in a couple spots. Given the logic inversion, the gdbserver code fails instead of succeeding. Fixed with the following patch. Seems fairly obvious, so I'll push it soon. gdbserver/ChangeLog: 2021-03-30 Luis Machado <luis.machado@linaro.org> * server.cc (handle_general_set, handle_query): Update variable to bool and fix verification logic.
2021-03-24AArch64: Add gdbserver MTE supportLuis Machado4-0/+76
Adds the AArch64-specific memory tagging support (MTE) by implementing the required hooks and checks for GDBserver. gdbserver/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * Makefile.in (SFILES): Add /../gdb/nat/aarch64-mte-linux-ptrace.c. * configure.srv (aarch64*-*-linux*): Add arch/aarch64-mte-linux.o and nat/aarch64-mte-linux-ptrace.o. * linux-aarch64-low.cc: Include nat/aarch64-mte-linux-ptrace.h. (class aarch64_target) <supports_memory_tagging> <fetch_memtags, store_memtags>: New method overrides. (aarch64_target::supports_memory_tagging) (aarch64_target::fetch_memtags) (aarch64_target::store_memtags): New methods.
2021-03-24AArch64: Add MTE register set support for GDB and gdbserverLuis Machado2-0/+36
AArch64 MTE support in the Linux kernel exposes a new register through ptrace. This patch adds the required code to support it. include/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * elf/common.h (NT_ARM_TAGGED_ADDR_CTRL): Define. gdb/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * aarch64-linux-nat.c (fetch_mteregs_from_thread): New function. (store_mteregs_to_thread): New function. (aarch64_linux_nat_target::fetch_registers): Update to call fetch_mteregs_from_thread. (aarch64_linux_nat_target::store_registers): Update to call store_mteregs_to_thread. * aarch64-tdep.c (aarch64_mte_register_names): New struct. (aarch64_cannot_store_register): Handle MTE registers. (aarch64_gdbarch_init): Initialize and setup MTE registers. * aarch64-tdep.h (gdbarch_tdep) <mte_reg_base>: New field. <has_mte>: New method. * arch/aarch64-linux.h (AARCH64_LINUX_SIZEOF_MTE): Define. gdbserver/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * linux-aarch64-low.cc (aarch64_fill_mteregset): New function. (aarch64_store_mteregset): New function. (aarch64_regsets): Add MTE register set entry. (aarch64_sve_regsets): Add MTE register set entry.
2021-03-24AArch64: Add target description/feature for MTE registersLuis Machado5-11/+30
This patch adds a target description and feature "mte" for aarch64. It includes one new register, tag_ctl, that can be used to configure the tag generation rules and sync/async modes. It is 64-bit in size. The patch also adjusts the code that creates the target descriptions at runtime based on CPU feature checks. gdb/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Take MTE flag into account. Slight refactor to hwcap flag checking. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. * aarch64-tdep.c (tdesc_aarch64_list): Add one more dimension for MTE. (aarch64_read_description): Add mte_p parameter and update to use it. Update the documentation. (aarch64_gdbarch_init): Update call to aarch64_read_description. * aarch64-tdep.h (aarch64_read_description): Add mte_p parameter. * arch/aarch64.c: Include ../features/aarch64-mte.c. (aarch64_create_target_description): Add mte_p parameter and update the code to use it. * arch/aarch64.h (aarch64_create_target_description): Add mte_p parameter. * features/Makefile (FEATURE_XMLFILES): Add aarch64-mte.xml. * features/aarch64-mte.c: New file, generated. * features/aarch64-mte.xml: New file. gdbserver/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * linux-aarch64-ipa.cc (get_ipa_tdesc): Update call to aarch64_linux_read_description. (initialize_low_tracepoint): Likewise. * linux-aarch64-low.cc (aarch64_target::low_arch_setup): Take MTE flag into account. * linux-aarch64-tdesc.cc (tdesc_aarch64_list): Add one more dimension for MTE. (aarch64_linux_read_description): Add mte_p parameter and update to use it. * linux-aarch64-tdesc.h (aarch64_linux_read_description): Add mte_p parameter.
2021-03-24AArch64: Add MTE CPU feature check supportLuis Machado2-0/+5
This patch is a preparation for the next patches implementing MTE. It just adds a HWCAP2 constant for MTE, creates a new generic arch/aarch64-mte-linux.h file and includes that file in the source files that will use it. gdb/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * Makefile.in (HFILES_NO_SRCDIR): Add arch/aarch64-mte-linux.h. * aarch64-linux-nat.c: Include arch/aarch64-mte-linux.h. * aarch64-linux-tdep.c: Likewise * arch/aarch64-mte-linux.h: New file. gdbserver/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * linux-aarch64-low.cc: Include arch/aarch64-mte-linux.h.
2021-03-24Unit tests for gdbserver memory tagging remote packetsLuis Machado2-0/+83
Add some unit testing to exercise the functions handling the qMemTags and QMemTags packets as well as feature support. gdbserver/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * server.cc (test_memory_tagging_functions): New function. (captured_main): Register test_memory_tagging_functions.
2021-03-24GDBserver remote packet support for memory taggingLuis Machado7-25/+240
This patch adds the generic remote bits to gdbserver so it can check for memory tagging support and handle fetch tags and store tags requests. gdbserver/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * remote-utils.cc (decode_m_packet_params): Renamed from ... (decode_m_packet): ... this, which now calls decode_m_packet_params. Make char * param/return const char *. (decode_M_packet): Use decode_m_packet_params and make char * param const char *. * remote-utils.h (decode_m_packet_params): New prototype. (decode_m_packet): Constify char pointers. (decode_M_packet): Likewise. * server.cc (create_fetch_memtags_reply) (parse_store_memtags_request): New functions. (handle_general_set): Handle the QMemTags packet. (parse_fetch_memtags_request): New function. (handle_query): Handle the qMemTags packet and advertise memory tagging support. (captured_main): Initialize memory tagging flag. * server.h (struct client_state): Initialize memory tagging flag. * target.cc (process_stratum_target::supports_memory_tagging) (process_stratum_target::fetch_memtags) (process_stratum_target::store_memtags): New methods. * target.h: Include gdbsupport/byte-vector.h. (class process_stratum_target) <supports_memory_tagging> <fetch_memtags, store_memtags>: New class virtual methods. (target_supports_memory_tagging): Define.
2021-03-22gdbserver: convert the global dll list into a process_info fieldTankut Baris Aktemur6-20/+70
The 'all_dlls' list is global. This would cause the complete dll list to be reported for individual processes. Move the list into the process_info struct. Currently the dll list is used only by the win32-low target, which does not support the multi-process feature. Therefore, it practically does not matter whether the list is global or per-process. However, there may be targets that are outside the binutils-gdb repo (e.g. we, at Intel, have such a target) that have multi-process and use the dll list. So, it makes sense to do the right thing. gdbserver/ChangeLog: 2021-03-22 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * inferiors.h (struct process_info) <all_dlls, dlls_changed>: New fields. * dll.h (loaded_dll) (unloaded_dll): Declare an overloaded version that takes a proc parameter. * dll.cc (loaded_dll) (unloaded_dll): Implement the overloaded versions. (clear_dlls): Clear all process' dll lists. (all_dlls, dlls_changed): Remove the global variables. * remote-utils.cc (prepare_resume_reply): Update to consider a dll list per proc. * server.cc (handle_qxfer_libraries): Ditto. (handle_v_attach): Ditto. (captured_main): Ditto.
2021-02-23gdbserver: linux-low: make linux_process_target::filter_event return voidSimon Marchi3-14/+21
Same as the previous patch, but for GDBserver. The return value of this method is never used, change it to return void. gdbserver/ChangeLog: * linux-low.cc (linux_process_target::filter_event): Return void. * linux-low.h (class linux_process_target) <filter_event>: Return void. Change-Id: I79e5dc04d9b21b9f01c6d675fa463d1b1a703b3a
2021-02-12Add stdio support to gdbreplayTom Tromey2-21/+45
I've been using gdbreplay to help debug an intermittent failure, and I wanted it to be a little simpler to use. This patch adds support for "-" as the "address" argument. With this patch you can do: (gdb) target remote | gdbreplay logfile - ... and not have to start gdbreplay in a separate shell. 2021-02-12 Tom Tromey <tromey@adacore.com> * gdbreplay.cc (remote_desc): Remove. (remote_desc_in, remote_desc_out): New globals. (remote_close): Update. (remote_open): Handle "-". (remote_open): Update. (logchar): Log to stderr. (expect, play): Update.
2021-02-12Minor constification in gdbreplayTom Tromey2-2/+6
I noticed a spot in gdbreplay where "const" could be used. 2021-02-12 Tom Tromey <tromey@adacore.com> * gdbreplay.cc (remote_open): Constify.
2021-02-05gnulib: update to 776af40e0Paul E. Murphy3-1/+12
This fixes PR27184, a failure to compile gdb due to cdefs.h being out of sync with glibc on ppc64le targets which are compiled with -mabi=ieeelongdouble and glibc 2.32. Likewise, update usage of _GL_ATTRIBUTE_FORMAT_PRINTF to _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD. Likewise, disable newly added rpl_free gnulib api in gdbserver support libraries. Likewise, undefine read/write macros before redefining them on mingw targets. Likewise, wrap C++ usage of free with GNULIB_NAMESPACE namespace as needed. Change-Id: I86517613c0d8ac8f5ea45bbc4ebe2b54a3aef29f