aboutsummaryrefslogtreecommitdiff
path: root/gdbserver/netbsd-low.cc
AgeCommit message (Collapse)AuthorFilesLines
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-12-13gdbserver: replace direct assignments to current_threadTankut Baris Aktemur1-1/+1
Replace the direct assignments to current_thread with switch_to_thread. Use scoped_restore_current_thread when appropriate. There is one instance remaining in linux-low.cc's wait_for_sigstop. This will be handled in a separate patch. Regression-tested on X86-64 Linux using the native-gdbserver and native-extended-gdbserver board files.
2021-10-21gdb, gdbserver: make target_waitstatus safeSimon Marchi1-30/+20
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-04-12gdbserver: constify the 'pid_to_exec_file' target opTankut Baris Aktemur1-2/+2
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-01-01Update copyright year range in all GDB filesJoel Brobecker1-1/+1
This commits the result of running gdb/copyright.py as per our Start of New Year procedure... gdb/ChangeLog Update copyright year range in copyright header of all GDB files.
2020-10-26gdb::handle_eintr, remove need to specify return typePedro Alves1-5/+5
This eliminates the need to specify the return type when using handle_eintr. We let the compiler deduce it for us. Also, use lowercase for function parameter names. Uppercase should only be used on template parameters. gdb/ChangeLog: * nat/linux-waitpid.c: Include "gdbsupport/eintr.h". (my_waitpid): Use gdb::handle_eintr. gdbserver/ChangeLog: * netbsd-low.cc (netbsd_waitpid, netbsd_process_target::kill) (netbsd_qxfer_libraries_svr4): Use gdb::handle_eintr without explicit type. gdbsupport/ChangeLog: * eintr.h (handle_eintr): Replace Ret template parameter with ErrorValType. Use it as type of the failure value. Deduce the function's return type using decltype. Use lowercase for function parameter names.
2020-10-13Remove unneeded netbsd_add_process()Kamil Rytarowski1-14/+1
Currently it does not add any value. The netbsd_tdesc local variable is no longer needed. Remove it. The tdesc value is set by the low target now. gdbserver/ChangeLog: * netbsd-low.cc (netbsd_tdesc): Remove. (netbsd_add_process): Likewise. (netbsd_process_target::create_inferior): Update.
2020-10-07Stop passing netbsd_process_target to local functionsKamil Rytarowski1-22/+23
Switch from target->read_memory to netbsd_nat::read_memory and cleanup the code. No functional change. gdbserver/ChangeLog: * netbsd-low.cc (get_dynamic, get_r_debug, read_one_ptr) (netbsd_qxfer_libraries_svr4): Remove "target" argument and update. (netbsd_process_target::qxfer_libraries_svr4): Update.
2020-10-07Fix whitespace formattingKamil Rytarowski1-2/+2
gdbserver/ChangeLog: * netbsd-low.cc: Fix whitespace formatting. * netbsd-amd64-low.cc: Likewise.
2020-10-07Add common write_memory and read_memory NetBSD routinesKamil Rytarowski1-59/+2
Instead of sharing the native-only code with all BSDs with slightly different semantics of the kernels, share the NetBSD-only behavior beteen the NetBSD native and gdbserver setup. NetBSD does not differentiate the address space I and D in the operations (contrary to OpenBSD). NetBSD handles EACCES that integrates with NetBSD specific PaX MPROTECT error handling. Add a verbose message in the native client that an operation could be cancelled due to PaX MPROTECT setup. gdb/ChangeLog: * nat/netbsd-nat.c (write_memory, read_memory): Add. * nat/netbsd-nat.h (write_memory, read_memory): Likewise. * nbsd-nat.c (nbsd_nat_target::xfer_partial): Update. gdbserver/ChangeLog: * netbsd-low.cc (netbsd_process_target::read_memory) (netbsd_process_target::write_memory): Update.
2020-10-02Refactor the NetBSD amd64 gdbserver supportKamil Rytarowski1-8/+5
Replace the pre-C++ construct of netbsd_target_ops, netbsd_regset_info and netbsd_tdesc with C++ inheritance approach found in the Linux gdbserver code. Add netbsd_amd64_target, that inherits from the netbsd_process_target class and add proper singleton object for the_netbsd_target, initialized from netbsd_amd64_target. Call low_arch_setup () on post process creation, which sets machine specific properties of the traced process. Remove global singleton the_netbsd_target object from the generic gdbserver code. This refactoring introduces no functional change from the end-user point of view. gdbserver/ChangeLog: * netbsd-amd64-low.cc (netbsd_x86_64_arch_setup): Remove. (netbsd_target_regsets): Now const. (the_low_target): Remove. (class netbsd_amd64_target, the_netbsd_amd64_target) (the_netbsd_target): Add. * netbsd-low.cc (netbsd_process_target::post_create_inferior): Call low_arch_setup (). (netbsd_process_target::fetch_registers) (netbsd_process_target::store_registers, initialize_low): Update. (the_netbsd_target): Remove. * netbsd-low.h (netbsd_target_regsets, netbsd_target_ops) (the_low_target, netbsd_tdesc): Remove. (netbsd_process_target::get_regs_info) (netbsd_process_target::low_arch_setup): Add.
2020-09-18Make target_wait options use enum flagsTom Tromey1-3/+5
This changes TARGET_WNOHANG to be a member of an enum, rather than a define, and also adds a DEF_ENUM_FLAGS_TYPE for this type. Then, it changes target_wait and the various target wait methods to use this type rather than "int". This didn't catch any bugs, but it seems like a decent cleanup nevertheless. I did not change deprecated_target_wait_hook, since that's only used out-of-tree (by Insight), and there didn't seem to be a need. I can't build some of these targets, so I modified them on a best-effort basis. I don't think this patch should go in before the release branch is made. gdb/ChangeLog 2020-09-18 Tom Tromey <tromey@adacore.com> * windows-nat.c (struct windows_nat_target) <wait>: Update. (windows_nat_target::wait): Update. * target/wait.h (enum target_wait_flag): New. Use DEF_ENUM_FLAGS_TYPE. * target/target.h (target_wait): Change type of options. * target.h (target_options_to_string, default_target_wait): Update. (struct target_ops) <wait>: Change type of options. * target.c (target_wait, default_target_wait, do_option): Change type of "options". (target_options_to_string): Likewise. * target-delegates.c: Rebuild. * target-debug.h (target_debug_print_target_wait_flags): Rename from target_debug_print_options. * sol-thread.c (class sol_thread_target) <wait>: Update. (sol_thread_target::wait): Update. * rs6000-nat.c (class rs6000_nat_target) <wait>: Update. (rs6000_nat_target::wait): Update. * remote.c (class remote_target) <wait, wait_ns, wait_as>: Update. (remote_target::wait_ns, remote_target::wait_as): Change type of "options". (remote_target::wait): Update. * remote-sim.c (struct gdbsim_target) <wait>: Update. (gdbsim_target::wait): Update. * record-full.c (class record_full_base_target) <wait>: Update. (record_full_wait_1): Change type of "options". (record_full_base_target::wait): Update. * record-btrace.c (class record_btrace_target) <wait>: Update. (record_btrace_target::wait): Update. * ravenscar-thread.c (struct ravenscar_thread_target) <wait>: Update. (ravenscar_thread_target::wait): Update. * procfs.c (class procfs_target) <wait>: Update. (procfs_target::wait): Update. * obsd-nat.h (class obsd_nat_target) <wait>: Update. * obsd-nat.c (obsd_nat_target::wait): Update. * nto-procfs.c (struct nto_procfs_target) <wait>: Update. (nto_procfs_target::wait): Update. * nbsd-nat.h (struct nbsd_nat_target) <wait>: Update. * nbsd-nat.c (nbsd_wait): Change type of "options". (nbsd_nat_target::wait): Update. * linux-thread-db.c (class thread_db_target) <wait>: Update. (thread_db_target::wait): Update. * linux-nat.h (class linux_nat_target) <wait>: Update. * linux-nat.c (linux_nat_target::wait): Update. (linux_nat_wait_1): Update. * infrun.c (do_target_wait_1, do_target_wait): Change type of "options". * inf-ptrace.h (struct inf_ptrace_target) <wait>: Update. * inf-ptrace.c (inf_ptrace_target::wait): Update. * go32-nat.c (struct go32_nat_target) <wait>: Update. (go32_nat_target::wait): Update. * gnu-nat.h (struct gnu_nat_target) <wait>: Update. * gnu-nat.c (gnu_nat_target::wait): Update. * fbsd-nat.h (class fbsd_nat_target) <wait>: Update. * fbsd-nat.c (fbsd_nat_target::wait): Update. * darwin-nat.h (class darwin_nat_target) <wait>: Update. * darwin-nat.c (darwin_nat_target::wait): Update. * bsd-uthread.c (struct bsd_uthread_target) <wait>: Update. (bsd_uthread_target::wait): Update. * aix-thread.c (class aix_thread_target) <wait>: Update. (aix_thread_target::wait): Update. gdbserver/ChangeLog 2020-09-18 Tom Tromey <tromey@adacore.com> * netbsd-low.h (class netbsd_process_target) <wait>: Update. * netbsd-low.cc (netbsd_waitpid, netbsd_wait) (netbsd_process_target::wait): Change type of target_options. * win32-low.h (class win32_process_target) <wait>: Update. * win32-low.cc (win32_process_target::wait): Update. * target.h (class process_stratum_target) <wait>: Update. (mywait): Update. * target.cc (mywait, target_wait): Change type of "options". * linux-low.h (class linux_process_target) <wait, wait_1>: Update. * linux-low.cc (linux_process_target::wait) (linux_process_target::wait_1): Update.
2020-09-10Add minimal and functional NetBSD/amd64 gdbserverKamil Rytarowski1-0/+1327
Implement the following functionality: create_inferior, post_create_inferior, attach, kill, detach, mourn, join, thread_alive, resume, wait, fetch_registers, store_registers, read_memory, write_memory, request_interrupt, supports_read_auxv, read_auxv, supports_hardware_single_step, sw_breakpoint_from_kind, supports_z_point_type, insert_point, remove_point, stopped_by_sw_breakpoint, supports_qxfer_siginfo, qxfer_siginfo, supports_stopped_by_sw_breakpoint, supports_non_stop, supports_multi_process, supports_fork_events, supports_vfork_events, supports_exec_events, supports_disable_randomization, supports_qxfer_libraries_svr4, qxfer_libraries_svr4, supports_pid_to_exec_file, pid_to_exec_file, thread_name, supports_catch_syscall. The only CPU architecture supported: x86_64. Implement only support for hardware assisted single step and software breakpoint. Implement support only for regular X86 registers, thus no FPU. gdbserver/ChangeLog: * netbsd-low.cc: Add. * netbsd-low.h: Likewise. * netbsd-amd64-low.cc: Likewise. * Makefile.in (SFILES): Register "netbsd-low.cc", "netbsd-low.h", "netbsd-amd64-low.cc". * configure.srv: Add x86_64-*-netbsd*.