aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
AgeCommit message (Collapse)AuthorFilesLines
2024-12-19gdb, gdbserver: introduce the 'x' RSP packet for binary memory readTankut Baris Aktemur3-7/+112
Introduce an RSP packet, 'x', for reading from the remote server memory in binary format. The binary write packet, 'X' already exists. The 'x' packet is essentially the same as 'm', except that the returned data is in binary format. For transferring relatively large data from the memory of the remote process, the 'x' packet can reduce the transfer costs. For example, without this patch, fetching ~100MB of data from a remote target takes (gdb) dump binary memory temp.o 0x00007f3ba4c576c0 0x00007f3bab709400 2024-03-13 16:17:42.626 - command started 2024-03-13 16:18:24.151 - command finished Command execution time: 32.136785 (cpu), 41.525515 (wall) (gdb) whereas with this patch, we obtain (gdb) dump binary memory temp.o 0x00007fec39fce6c0 0x00007fec40a80400 2024-03-13 16:20:48.609 - command started 2024-03-13 16:21:16.873 - command finished Command execution time: 20.447970 (cpu), 28.264202 (wall) (gdb) We see improvements not only when reading bulk data as above, but also when making a large number of small memory access requests. For example, without this patch: (gdb) pipe x/100000xw $pc | wc -l 2024-03-13 16:04:57.112 - command started 25000 2024-03-13 16:05:10.798 - command finished Command execution time: 9.952364 (cpu), 13.686581 (wall) With this patch: (gdb) pipe x/100000xw $pc | wc -l 2024-03-13 16:06:48.160 - command started 25000 2024-03-13 16:06:57.750 - command finished Command execution time: 6.541425 (cpu), 9.589839 (wall) (gdb) Another example, where we create a core file of a GDB process. (gdb) gcore /tmp/core.1 ... Command execution time: 85.496967 (cpu), 133.224373 (wall) vs. (gdb) gcore /tmp/core.1 ... Command execution time: 48.328885 (cpu), 115.032289 (wall) Regression-tested on X86-64 using the unix (default) and native-extended-gdbserver board files. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
2024-12-19gdbserver: allow suppressing the next putpkt remote-debug logTankut Baris Aktemur3-5/+28
When started with the --debug=remote flag, gdbserver enables the debug logs for the received and sent remote packets. If the packet contents are too long or contain verbatim binary data, printing the contents may create noise in the logs or even distortion in the terminal output. Introduce a function, `suppress_next_putpkt_log`, that allows omitting the contents of a sent package in the logs. This can be useful when a certain packet handler knows that it is sending binary data. My first attempt was to implement this mechanism by passing an extra parameter to putpt_binary_1 that could be controlled by the caller, putpkt_binary or putpkt. However, all qxfer handlers, regardless of whether they send binary or ascii data, cause the data to be sent via putpkt_binary. Hence, the solution was going to be either too suppressive or too intrusive. I opted for the approach where a package handler would suppress the log explicitly. Approved-By: Tom Tromey <tom@tromey.com>
2024-12-18Run check-include-guards.pyTom Tromey2-2/+2
This patch is the result of running check-include-guards.py on the current tree. Running it a second time causes no changes. Reviewed-By: Tom de Vries <tdevries@suse.de>
2024-12-17gdbserver: return tracked register status in regcache_raw_read_unsignedTankut Baris Aktemur1-1/+1
In regcache_raw_read_unsigned, we unconditionally return REG_VALID as the register status. This does not seem right, since the register may in fact be in another state, such as REG_UNAVAILABLE. Return the tracked status. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-12-17gdbserver: rename regcache's registers_valid to registers_fetchedTankut Baris Aktemur2-12/+13
The registers_valid field of the regcache struct is used for tracking whether we have attempted to fetch all the registers from the target. Its name does not reflect this well, I think. It falsely gives the impression that all the registers are valid. This may conflict an individual register status, which could be REG_UNAVAILABLE. To better reflect the purpose, rename the field to "registers_fetched". Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-12-17gdbserver: boolify regcache fieldsTankut Baris Aktemur2-8/+8
The registers_valid and registers_owned fields of the regcache struct are of type int. Make them bool. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-12-17gdbserver: check for nullptr condition in regcache::get_register_statusTankut Baris Aktemur1-1/+4
A regcache can be initialized with a register value buffer, in which case, the register_status pointer is null. This condition is checked in set_register_status, but not in get_register_status. Do this check for consistence and safety. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-12-17gdbserver: convert regcache_cpy into regcache::copy_fromTankut Baris Aktemur3-11/+12
Convert the free `regcache_cpy` function to a method of the regcache struct. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-12-17gdbserver: boolify and defaultize the 'fetch' parameter of get_thread_regcacheTankut Baris Aktemur12-24/+24
Boolify the 'fetch' parameter of the get_thread_regcache function. All of the current uses pass true for this parameter. Therefore, define its default value as true and remove the argument from the uses. We still keep the parameter, though, to give downstream targets the option to obtain a regcache without having to fetch the whole contents. Our (Intel) downstream target is an example. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-12-17gdbserver: by-pass regcache to access tdesc onlyTankut Baris Aktemur3-22/+9
The `get_thread_regcache` function has a `fetch` option to skip fetching the registers from the target. It seems this option is set to false only at uses where we just need to access the tdesc through the regcache of the current thread, as in struct regcache *regcache = get_thread_regcache (current_thread, 0); ... regcache->tdesc ... Since the tdesc of a regcache is set from the process of the thread that owns the regcache, we can simplify the code to access the tdesc via the process, as in ... current_process ()->tdesc ... This is intended to be a refactoring with no behavioral change. Tested only for the linux-x86-low target. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-12-12Add text to gdbreplay --help outputTom Tromey1-3/+29
I noticed that gdbreplay --help is rather sparse -- it doesn't even mention the names of the options it accepts. This patch updates the help output to be more complete. Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-12-11Fix gdbreplay checksum calculationTom Tromey1-20/+11
I needed to use gdbreplay today. It didn't work quite right, and using "set debug remote 1" showed that gdb was rejecting some responses like: [remote] Sending packet: $vCont?#49 [remote] Junk: #vCont? [remote] Junk: 8vCont? [remote] Junk: 3vCont? [remote] Received Ack The checksum recalculation seems to have gone wrong. Looking at the code, it seems like 'where_csum' is calculated inconsistently: in the main loop it is after the '#' but in the "== 0" case it is before the '#'. This patch fixes the problem and also avoids a string copy. CC: Alexandra Hájková <ahajkova@redhat.com> Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-12-09gdbserver: remove 'struct' in 'struct thread_info' declarationsTankut Baris Aktemur16-78/+78
Remove the 'struct' keyword in occurrences of 'struct thread_info'. This is a code clean-up. Tested by rebuilding. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-12-07gdbserver: simplify win32 process removalSimon Marchi5-37/+5
In the spirit of encapsulation, I'm looking to remove the need for external code to access the "ptid -> thread" map of process_info, making it an internal implementation detail. The only remaining use is in function clear_inferiors, and it led me down this rabbit hole: - clear_inferiors is really only used by the Windows port and doesn't really make sense in the grand scheme of things, I think (when would you want to remove all threads of all processes, without removing those processes?) - ok, so let's remove clear_inferiors and inline the code where it's called, in function win32_clear_inferiors - the Windows port does not support multi-process, so it's not really necessary to loop over all processes like this: for_each_process ([] (process_info *process) { process->thread_list ().clear (); process->thread_map ().clear (); }); We could just do: current_process ()->thread_list ().clear (); current_process ()->thread_map ().clear (); (or pass down the process from the caller, but it's not important right now) - so, the code that we've inlined in win32_clear_inferiors does 3 things: - clear the process' thread list and map (which deletes the thread_info objects) - clear the dll list, which just basically frees some objects - switch to no current process / no current thread - let's now look at where this win32_clear_inferiors function is used: - in win32_process_target::kill, where the process is removed just after - in win32_process_target::detach, where the process is removed just after - in win32_process_target::wait, when handling a process exit. After this returns, we could be in handle_target_event (if async) or resume (if sync), both in `server.cc`. In both of these cases, target_mourn_inferior gets called, we end up in win32_process_target::mourn, which removes the process - in all 3 cases above, we end up removing the process, which takes care of the 3 actions listed above: - the thread list and map get cleared when the process gets destroyed - same with the dll list - remove_process switches to no current process / current thread if the process being removed is the current one - I conclude that it's probably unnecessary to do the cleanup in win32_clear_inferiors, because it's going to get done right after anyway. Therefore, this patch does: - remove clear_inferiors, remove the call in win32_clear_inferiors - remove clear_dlls, which is now unused - remove process_info::thread_map, which is now unused - rename win32_clear_inferiors to win32_clear_process, which seems more accurate win32_clear_inferiors also does: for_each_thread (delete_thread_info); which also makes sure to delete all threads, but it also deletes the Windows private data object (windows_thread_info), so I'll leave this one there for now. But if we could make the thread private data destruction automatic, on thread destruction, it could be removed, I think. There should be no user-visible change with this patch. Of course, operations don't happen in the same order as before, so there might be some important detail I'm missing. I'm only able to build-test this, if someone could give it a test run on Windows, it would be appreciated. Change-Id: I4a560affe763a2c965a97754cc02f3083dbe6fbf
2024-12-06gdb, gdbserver, gdbsupport: remove some unused gdb_vecs.h includesSimon Marchi2-2/+0
Remove some includes reported as unused by clangd. Add some to files that actually need it. Change-Id: I01c61c174858c1ade5cb54fd7ee1f582b17c3363
2024-12-06Reduce WOW64 code duplicationHannes Domani2-141/+53
Currently we have duplicate code for each place where windows_thread_info::context is touched, since for WOW64 processes it has to do the equivalent with wow64_context instead. For example this code...: #ifdef __x86_64__ if (windows_process.wow64_process) { th->wow64_context.ContextFlags = WOW64_CONTEXT_ALL; CHECK (Wow64GetThreadContext (th->h, &th->wow64_context)); ... } else #endif { th->context.ContextFlags = CONTEXT_DEBUGGER_DR; CHECK (GetThreadContext (th->h, &th->context)); ... } ...changes to look like this instead: windows_process.with_context (th, [&] (auto *context) { context->ContextFlags = WindowsContext<decltype(context)>::all; CHECK (get_thread_context (th->h, context)); ... } The actual choice if context or wow64_context are used, is handled by this new function in windows_process_info: template<typename Function> auto with_context (windows_thread_info *th, Function function) { #ifdef __x86_64__ if (wow64_process) return function (th != nullptr ? th->wow64_context : nullptr); else #endif return function (th != nullptr ? th->context : nullptr); } The other parts to make this work are the templated WindowsContext class which give the appropriate ContextFlags for both types. And there are also overloaded helper functions, like in the case of get_thread_context here, call either GetThreadContext or Wow64GetThreadContext. According git log --stat, this results in 120 lines less code. Approved-By: Tom Tromey <tom@tromey.com>
2024-12-05gdbserver/win32-low.cc: remove use of `all_threads`Simon Marchi2-3/+12
Fix this: gdbserver/win32-low.cc: In function ‘void child_delete_thread(DWORD, DWORD)’: gdbserver/win32-low.cc:192:7: error: ‘all_threads’ was not declared in this scope; did you mean ‘using_threads’? 192 | if (all_threads.size () == 1) | ^~~~~~~~~~~ | using_threads Commit 9f77b3aa0bfc ("gdbserver: change 'all_processes' and 'all_threads' list type") changed the type of `all_thread` to an intrusive_list, without changing this particular use, which broke the build because an intrusive_list doesn't know its size, so it doesn't have a `size()` method. The subsequent commit removed `all_threads`, leading to the error above. Fix it by using the number of threads of the concerned process instead. My rationale: as far as I know, GDBserver on Windows only supports one process at a time, so there's no need to iterate over all processes. If we made GDBserver for Windows support multiple processes, my intuition is that we'd want this check to use the number of threads of the concerned process, not the number of threads overall. Add the method `process_info::thread_count`, to get the number of threads of the process. I'm not really sure what this check is for in the first place, Hannes Domani said that this check didn't seem to trigger on Windows 7 and 11. Perhaps it was necessary before. Change-Id: I84d6226532b887d99248cf3be90f5065fb7a074a Tested-By: Hannes Domani <ssbssa@yahoo.de>
2024-12-05gdbserver: add and use `process_info::find_thread(ptid)`Simon Marchi2-12/+20
Add an overload of `process_info::find_thread` that finds a thread by ptid. Use it in two spots. Change-Id: I2b7fb819bf4f83f7bd37f8641c38e878119b3814
2024-12-04gdbserver: make thread_target_data a method of thread_infoSimon Marchi6-19/+13
Make the field private, change the free function to be a method. Change-Id: I05010e7d1bd58ce3895802eb263c029528427758 Approved-By: Tom Tromey <tom@tromey.com>
2024-12-04gdbserver: make thread_regcache_data / set_thread_regcache_data methods of ↵Simon Marchi4-25/+13
thread_info Make the field private, change the free functions to be methods. Change-Id: Ifd8ed2775dddefc73a0e00126182e1db02688af4 Approved-By: Tom Tromey <tom@tromey.com>
2024-12-04gdbserver: make get_thread_lwp a functionSimon Marchi1-1/+5
Replace the macro with a static inline function. Change-Id: I1cccf5b38d6a412d251763f0316902b07cc28d16 Approved-By: Tom Tromey <tom@tromey.com>
2024-12-04gdbserver: remove macro get_lwp_threadSimon Marchi7-54/+52
I was thinking of changing this macro to a function, but I don't think it adds much value over just accessing the field directly. Change-Id: I5dc63e9db0773549c5b55a1279212e2d1213f50c Approved-By: Tom Tromey <tom@tromey.com>
2024-12-02gdb, gdbserver, gdbsupport: flatten and sort some list in configure filesSimon Marchi2-12/+84
This makes the lists easier sort read and modify. There are no changes in the generated config.h files, so I'm confident this brings no functional changes. Change-Id: Ib6b7fc532bcd662af7dbb230070fb1f4fc75f86b
2024-11-26nios2: Remove all GDB support for Nios II targets.Sandra Loosemore3-298/+0
Intel has EOL'ed the Nios II architecture, and it's time to remove support from all toolchain components before it gets any more bit-rotten from lack of maintenance or regular testing.
2024-11-25gdbreplay: Calculate the checksum if missingAlexandra Hájková1-4/+48
Recalculate the checksum and replace whatever is at the end of the packet with the newly calculated checksum. Then replay the packet with the checksum added. The motivation for this change is that I'd like to add a TCL test which starts a communication with gdbsever setting the remotelog file. Then, it modifies the remotelog, injects an error message instead of the expected replay to some packet in order to test GDB reacts to the error response properly. Approved-By: Tom Tromey <tom@tromey.com>
2024-11-23[gdb/contrib] Add two rules in common-misspellings.txtTom de Vries1-1/+1
Eli mentioned [1] that given that we use US English spelling in our documentation, we should use "behavior" instead of "behaviour". In wikipedia-common-misspellings.txt there's a rule: ... behavour->behavior, behaviour ... which leaves this as a choice. Add an overriding rule to hardcode the choice to common-misspellings.txt: ... behavour->behavior ... and add a rule to rewrite behaviour into behavior: ... behaviour->behavior ... and re-run spellcheck.sh on gdb*. Tested on x86_64-linux. [1] https://sourceware.org/pipermail/gdb-patches/2024-November/213371.html
2024-11-22Use appropriate context flags for Wow64 processesHannes Domani1-7/+23
When I implemented debugging of Wow64 processes, I missed that there are extra ContextFlags defines for them. It's a bit surprising that the wrong ones actually worked, except that CONTEXT_EXTENDED_REGISTERS is not available for x86_64, and they are needed for i686, since that's where the xmm registers are stored. So this replaces the ContextFlags values with their WOW64_* equivalents. On gdbserver this also duplicates the fallback logic if the GetThreadContext call failed with CONTEXT_EXTENDED_REGISTERS. Fixes these fails: FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm0 FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm0 FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm1 FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm1 FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm2 FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm2 FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm3 FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm3 FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm4 FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm4 FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm5 FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm5 FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm6 FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm6 FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm7 FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm7 FAIL: gdb.arch/i386-sse.exp: check contents of data[0] FAIL: gdb.arch/i386-sse.exp: check contents of data[1] FAIL: gdb.arch/i386-sse.exp: check contents of data[2] FAIL: gdb.arch/i386-sse.exp: check contents of data[3] FAIL: gdb.arch/i386-sse.exp: check contents of data[4] FAIL: gdb.arch/i386-sse.exp: check contents of data[5] FAIL: gdb.arch/i386-sse.exp: check contents of data[6] FAIL: gdb.arch/i386-sse.exp: check contents of data[7] Approved-By: Tom Tromey <tom@tromey.com>
2024-11-22[gdbsupport] Add gdb::{waitpid,read,write,close}Tom de Vries1-5/+5
We have gdb::handle_eintr, which allows us to rewrite: ... ssize_t ret; do { errno = 0; ret = ::write (pipe[1], "+", 1); } while (ret == -1 && errno == EINTR); ... into: ... ssize_t ret = gdb::handle_eintr (-1, ::write, pipe[1], "+", 1); ... However, the call to write got a bit mangled, requiring effort to decode it back to its original form. Instead, add a new function gdb::write that allows us to write: ... ssize_t ret = gdb::write (pipe[1], "+", 1); ... Likewise for waitpid, read and close. Tested on x86_64-linux.
2024-11-12gdbserver: pass osabi to GDB in more target descriptionsAndrew Burgess16-21/+46
Problem Description ------------------- On a Windows machine I built gdbserver, configured for the target 'x86_64-w64-mingw32', then on a GNU/Linux machine I built GDB with support for all target (--enable-targets=all). On the Windows machine I start gdbserver with a small test binary: $ gdbserver 192.168.129.25:54321 C:\some\directory\executable.exe On the GNU/Linux machine I start GDB without the test binary, and connect to gdbserver. As I have not given GDB the test binary, my expectation is that GDB would connect to gdbserver and then download the file over the remote protocol, but instead I was presented with this message: (gdb) target remote 192.168.129.25:54321 Remote debugging using 192.168.129.25:54321 warning: C:\some\directory\executable.exe: No such file or directory. 0x00007ffa3e1e1741 in ?? () (gdb) What I found is that if I told GDB where to find the binary, like this: (gdb) file target:C:/some/directory/executable.exe A program is being debugged already. Are you sure you want to change the file? (y or n) y Reading C:/some/directory/executable.exe from remote target... warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead. Reading C:/some/directory/executable.exe from remote target... Reading symbols from target:C:/some/directory/executable.exe... (gdb) then GDB would download the executable. The Actual Issue ---------------- I tracked the problem down to exec_file_find (solib.c). The remote target was passing an absolute Windows filename (beginning with "C:/" in this case), but in exec_file_find GDB was failing the IS_TARGET_ABSOLUTE_PATH call, and so was treating the filename as relative. The IS_TARGET_ABSOLUTE_PATH call was failing because GDB thought that the file system kind was "unix", and as the filename didn't start with a "/" it assumed the filename was not absolute. But I'm connecting to a Windows target and 'target-file-system-kind' was set to "auto", so GDB should be figuring out that the target file-system is "dos-based". Looking in effective_target_file_system_kind (filesystem.c), we find that the logic of "auto" is delegated to the current gdbarch. However in windows-tdep.c we see: set_gdbarch_has_dos_based_file_system (gdbarch, 1); So if we are using a Windows gdbarch we should have "dos-based" filesystems. What this means is that after connecting to the remote target GDB has selected the wrong gdbarch. What's happening is that the target description sent back by the remote target only includes the x86-64 registers. There's no information about which OS we're on. As a consequence, GDB picks the first x86-64 gdbarch which can handle the provided register set, which happens to be a GNU/Linux gdbarch. And indeed, there doesn't appear to be anywhere in gdbserver that sets the osabi on the target descriptions. Some target descriptions do have their osabi set when the description is created, e.g. in: gdb/arch/amd64.c - Sets GNU/Linux osabi when appropriate. gdb/arch/i386.c - Likewise. gdb/arch/tic6x.c - Always set GNU/Linux osabi. There are also some cases in gdb/features/*.c where the tdesc is set, but these locations are only called from GDB, not from gdbserver. This means that many target descriptions are created without an osabi, gdbserver does nothing to fix this, and the description is returned to GDB without an osabi included. This leaves GDB having to guess what the target osabi is, and in some cases, GDB can get this wrong. Proposed Solution ----------------- I propose to change init_target_desc so that it requires an gdb_osabi to be passed in, this will then be used to set the target_desc osabi field. I believe that within gdbserver init_target_desc is called for every target_desc, so this should mean that every target_desc has an opportunity to set the osabi to something sane. I did consider passing the osabi into the code which creates the target_desc objects, but that would require updating far more code, as each target has its own code for creating target descriptions. The approach taken here requires minimal changes and forces every user of init_target_desc to think about what the correct osabi is. In some cases, e.g. amd64, where the osabi is already set when the target_desc is created, the init_target_desc call will override the current value, however, we should always be replacing it with the same actual value. i.e. if the target_desc is created with the osabi set to GNU/Linux, then this should only happen when gdbserver is built for GNU/Linux, in which case the init_target_desc should also be setting the osabi to GNU/Linux. The Tricky Bits --------------- Some targets, like amd64, use a features based approach for creating target_desc objects, there's a function in arch/amd64.c which creates a target_desc, adds features too it, and returns the new target_desc. This target_desc is then passed to an init_target_desc call within gdbserver. This is the easy case to handle. Then there are other targets which instead have a fixed set of xml files, each of which is converted into a .dat file, which is then used to generate a .cc file, which is compiled into gdbserver. The generated .cc file creates the target_desc object and calls init_target_desc on it. In this case though the target description that is sent to GDB isn't generated from the target_desc object, but is instead the contents of the fixed xml file. For this case the osabi which we pass to init_target_desc should match the osabi that exists in the fixed xml file. Luckily, in the previous commit I copied the osabi information from the fixed xml files into the .dat files. So in this commit I have extended regdat.sh to read the osabi from the .dat file and use it in the generated init_target_desc call. The problem with some of these .dat base targets is that their fixed xml files don't currently contain any osabi information, and the file names don't indicate that they are Linux only (despite them currently only being used from gdbserver for Linux targets), so I don't currently feel confident adding any osabi information to these files. An example would be features/rs6000/powerpc-64.xml. For now I've just ignored these cases. The init_target_desc will use GDB_OSABI_UNKNOWN which is the default. This means that for these targets nothing changes from the current behaviour. But many other targets do now pass the osabi back. Targets that do pass the osabi back are improved with this commit. Conclusion ---------- Now when I connect to the Windows remote the target description returned includes the osabi name. With this extra information GDB selects the correct gdbarch object, which means that GDB understands the target has a "dos-based" file-system. With that correct GDB understands that the filename it was given is absolute, and so fetches the file from the remote as we'd like. Reviewed-By: Kevin Buettner <kevinb@redhat.com>
2024-11-12[gdb/tdep] Use raw_supply_part_zeroed for AArch64Tom de Vries2-0/+14
In gdb/aarch64-linux-tdep.c we find: ... gdb::byte_vector za_zeroed (za_bytes, 0); regcache->raw_supply (tdep->sme_za_regnum, za_zeroed); ... We can't use reg_buffer::raw_supply_zeroed here because only part of the register is written. Add raw_supply_part_zeroed, and use it instead. Likewise elsewhere in AArch64 tdep code. Tested on aarch64-linux. Approved-By: Luis Machado <luis.machado@arm.com>
2024-11-08gdbserver: remove pidof(process)Simon Marchi4-15/+10
This function doesn't seem so useful, use `process_info::pid` directly instead. Change-Id: I55d592f38b32a197957ed4c569993cd23a818cb4 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: remove pid_of(thread)Simon Marchi6-20/+11
This function doesn't seem so useful, use `thread_info::id::pid` directly instead. Change-Id: I7450c4223e5b0bf66788eeb5b070ab6f5287f798 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: remove lwpid_of(thread)Simon Marchi8-138/+118
This function doesn't seem so useful. Use `thread_info::id::lwp` directly. Change-Id: Ib4a86eeeee6c1342bc1c092f083589ce28009be1 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: remove ptid_of(thread)Simon Marchi7-60/+51
This function doesn't seem so useful. Use `thread_info::id` directly. Change-Id: I158cd06a752badd30f68424e329aa42d275e43b7 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: remove current_thread_ptidSimon Marchi1-13/+5
This function doesn't seem so useful. Use `thread_info::id` directly. Change-Id: I4ae4e7baa44e09704631a1c3a5a66e5b8b5a3594 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: remove current_ptid macroSimon Marchi7-9/+6
I think it just makes things more obscure. Use `thread_info::id` directly instead. Change-Id: I141d5fb08ebf45c13cc32c4bba62773249fcb356 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: remove get_thread_processSimon Marchi7-43/+21
Remove the `get_thread_process` function, use `thread_info::process` instead. In `server.cc`, use `current_process ()` instead of going through the current thread. Change-Id: Ifc61d65852e392d154b854a45d45df584ab3922e Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: make remove_thread a method of process_infoSimon Marchi6-11/+13
Same idea as the previous patch, but for `remove_thread`. Change-Id: I7e227655be5fcf29a3256e8389eb32051f27882d Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: make add_thread a method of process_infoSimon Marchi6-14/+11
Since thread_info objects are now basically children of process_info objects, I think that makes sense. Change-Id: I7f0a67b921b468e512851cb2f36015d1003412d7 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: add thread -> process backlinkSimon Marchi2-4/+11
In a few spots, we need to get to a process from a thread. Having a backlink from thread to process is cheap and makes the operation trivial, add it. Change-Id: I8a94b2919494b1dcaf954de2246386794308aa82 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-08gdbserver: remove for_each_thread(pid, func)Simon Marchi8-33/+24
Remove this overload, prefer to use `process_info::for_each_thread`. In many instances, the `process_info` is already available, so this saves a map lookup. In other instances, add the `process_info` lookup at the call site. In `linux-arm-low.cc` and `win32-i386-low.cc`, use `current_process ()` instead of `current_thread->id.pid ()`. I presume that if `current_process ()` and `current_thread` don't match, it's a bug orthogonal to this change. Change-Id: I751ed497cb1f313cf937b35125151bee9316fc51 Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2024-11-07gdbserver: add process specific thread list and mapStephan Rohr4-54/+223
Replace the servers global thread list with a process specific thread list and a ptid -> thread map similar to 'inferior::ptid_thread_map' on GDB side. Optimize the 'find_thread' and 'find_thread_ptid' functions to use std::unordered_map::find for faster lookup of threads without iterating over all processes and threads, if applicable. This becomes important when debugging applications with a large thread count, e.g., in the context of GPU debugging. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-11-07gdbserver: change 'all_processes' and 'all_threads' list typeStephan Rohr4-69/+39
This patch replaces the 'std::list' type of 'all_processes' and 'all_threads' with the more lightweight 'owning_intrusive_list' type. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-10-28gdbserver: remove unused include in gdbthread.hSimon Marchi3-1/+2
clangd reports gdbsupport/common-gdbthread.h as unused in gdbthread.h, which seems right, so remove it. Add it to two files that need it, but were relying on the now-removed include. Change-Id: I12916a044d0b15f346c4ad0e6527ce99a6d460e4
2024-10-28gdbserver: fix formatting in gdbthread.hSimon Marchi1-12/+9
Remove newlines after return type in declarations. Change-Id: I00c6f35e063024cf6674d532454b67e6d0d98a19
2024-10-22gdbserver: use 'gdb::function_view' in 'find_*' and 'for_each_*'Stephan Rohr3-121/+153
Remove the templated versions of 'find_thread', 'for_each_thread' and 'find_thread_in_random' and replace the template function argument with 'gdb::function_view'. The usage of 'gdb::function_view' produces less cryptic messages on errors and documents well the types of the parameters taken by the callback and its return type. Approved-By: Simon Marchi <simon.marchi@efficios.com>
2024-10-21gdbreplay: Add --debug-logging optionAlexandra Hájková2-23/+61
As gdbreplay communicates with GDB, it outputs all the remote protocol communication it reads from the remotelogfile to stderr. This patch disables this behavior by default but adds the new --debug-logging option which turns printing the packets to stderr on again. The motivation for this change is to make it possible to use gdbreplay with TCL tests. Printing the whole remotelog file out seems to overflow the expect cache wich causes gdbreplay to not to get the packet its expects and results in going out of sync with GDB. Other motivation is making communication between GDB and gdbreplay faster as printing bigger remotelogfile takes considerable amount of time. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Approved-By: Tom Tromey <tom@tromey.com>
2024-10-21gdbreplay: Use getopt_long to parse command line argumentsAlexandra Hájková1-13/+24
Approved-By: Tom Tromey <tom@tromey.com>
2024-10-21[gdb/contrib] Handle dot in spellcheck.shTom de Vries1-1/+1
Add handling of '.' in gdb/contrib/spellcheck.sh. While we're at, simplify the sed invocation by using a single s command instead of 3 s commands. Also introduce sed_join and grep_join. Fix the following common misspellings: ... bandwith -> bandwidth emmitted -> emitted immediatly -> immediately suprize -> surprise thru -> through transfered -> transferred ... Verified with shellcheck.
2024-10-11gdbserver: remove declaration of init_registers_arm_with_neonAndrew Burgess1-1/+0
The last use of init_registers_arm_with_neon was removed in this commit: commit 7cc17433020a62935e4d91053251fe900d83c7f0 Date: Fri Jul 19 15:04:48 2019 +0100 Arm: Use read_description funcs in gdbserver But the declaration was left around. Remove the declaration now.