aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2015-04-29 11:53:43 -0400
committerJohn Baldwin <jhb@FreeBSD.org>2016-01-19 08:19:00 -0800
commit6e9567fe2ab39d1de89ecc5105c17443b66c9b48 (patch)
tree0fce92274a2a5701778dea1b022534ca0b444df8 /gdb/configure
parentUse LWP IDs with ptrace register requests on FreeBSD. (diff)
downloadbinutils-gdb-6e9567fe2ab39d1de89ecc5105c17443b66c9b48.tar.gz
binutils-gdb-6e9567fe2ab39d1de89ecc5105c17443b66c9b48.tar.bz2
binutils-gdb-6e9567fe2ab39d1de89ecc5105c17443b66c9b48.zip
Add support for LWP-based threads on FreeBSD.
Older versions of FreeBSD supported userland threading via a pure user-space threading library (N threads scheduled on 1 process) and a N:M model (N threads scheduled on M LWPs). However, modern FreeBSD versions only support a M:M threading model where each user thread is backed by a dedicated LWP. This thread target only supports this threading model. It also uses ptrace to query and alter LWP state directly rather than using libthread_db to simplify the implementation. FreeBSD recently gained support for reporting LWP events (birth and death of LWPs). GDB will use LWP events when present. For older systems it fetches the list of LWPs in the to_update_thread_list target op to update the list of threads on each stop. This target supports scheduler locking by using ptrace to suspend individual LWPs as necessary before resuming a process. gdb/ChangeLog: * configure.ac: Check for support for LWP names on FreeBSD. * fbsd-nat.c [PT_LWPINFO] New variable debug_fbsd_lwp. [TDP_RFPPWAIT || HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME] (fbsd_fetch_kinfo_proc): Move function earlier. [PT_LWPINFO] (fbsd_thread_alive): New function. [PT_LWPINFO] (fbsd_pid_to_str): New function. [HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME] (fbsd_thread_name): New function. [PT_LWP_EVENTS] (fbsd_enable_lwp_events): New function. [PT_LWPINFO] (fbsd_add_threads): New function. [PT_LWPINFO] (fbsd_update_thread_list): New function. [PT_LWPINFO] New variable super_resume. [PT_LWPINFO] (resume_one_thread_cb): New function. [PT_LWPINFO] (resume_all_threads_cb): New function. [PT_LWPINFO] (fbsd_resume): New function. (fbsd_remember_child): Save full ptid instead of plain pid. (fbsd_is_child_pending): Return ptid of saved child process. (fbsd_wait): Include lwp in returned ptid and switch to LWP ptid on first stop. [PT_LWP_EVENTS] Handle LWP events. [TDP_RFPPWAIT] Include LWP in child ptid. (fbsd_post_startup_inferior) [PT_LWP_EVENTS]: Enable LWP events. (fbsd_post_attach) [PT_LWP_EVENTS]: Enable LWP events. Add threads for existing processes. (fbsd_nat_add_target) [PT_LWPINFO]: Set "to_thread_alive" to "fbsd_thread_alive". Set "to_pid_to_str" to "fbsd_pid_to_str". [HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME]: Set "to_thread_name" to "fbsd_thread_name". [PT_LWPINFO]: Set "to_update_thread_list" to "fbsd_update_thread_list". Set "to_has_thread_control" to "tc_schedlock". Set "to_resume" to "fbsd_resume". (_initialize_fbsd_nat): New function. * configure: Regenerate. * config.in: Regenerate. gdb/doc/ChangeLog: * gdb.texinfo (Debugging Output): Document "set/show debug fbsd-lwp".
Diffstat (limited to 'gdb/configure')
-rwxr-xr-xgdb/configure16
1 files changed, 16 insertions, 0 deletions
diff --git a/gdb/configure b/gdb/configure
index 11f91e31cbf..701cfcb0239 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12965,6 +12965,22 @@ $as_echo "#define HAVE_PT_GETXMMREGS 1" >>confdefs.h
fi
+# See if <sys/ptrace.h> supports LWP names on FreeBSD
+# Older FreeBSD versions don't have the pl_tdname member of
+# `struct ptrace_lwpinfo'.
+ac_fn_c_check_member "$LINENO" "struct ptrace_lwpinfo" "pl_tdname" "ac_cv_member_struct_ptrace_lwpinfo_pl_tdname" "#include <sys/ptrace.h>
+"
+if test "x$ac_cv_member_struct_ptrace_lwpinfo_pl_tdname" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME 1
+_ACEOF
+
+
+fi
+
+
+
# Detect which type of /proc is in use, such as for Solaris.
if test "${target}" = "${host}"; then