[09/31] Thread options & clone events (native Linux)

Message ID 20221212203101.1034916-10-pedro@palves.net
State New
Headers
Series Step over thread clone and thread exit |

Commit Message

Pedro Alves Dec. 12, 2022, 8:30 p.m. UTC
  This commit teaches the native Linux target about the
GDB_THREAD_OPTION_CLONE thread option.  It's actually simpler to just
continue reporting all clone events unconditionally to the core.
There's never any harm in reporting a clone event when the option is
disabled.  All we need to do is to report support for the option,
otherwise GDB falls back to use target_thread_events().

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19675
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27830
Change-Id: If90316e2dcd0c61d0fefa0d463c046011698acf9
---
 gdb/linux-nat.c | 7 +++++++
 gdb/linux-nat.h | 2 ++
 2 files changed, 9 insertions(+)
  

Comments

Andrew Burgess June 6, 2023, 1:43 p.m. UTC | #1
Pedro Alves <pedro@palves.net> writes:

> This commit teaches the native Linux target about the
> GDB_THREAD_OPTION_CLONE thread option.  It's actually simpler to just
> continue reporting all clone events unconditionally to the core.
> There's never any harm in reporting a clone event when the option is
> disabled.  All we need to do is to report support for the option,
> otherwise GDB falls back to use target_thread_events().
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19675
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27830
> Change-Id: If90316e2dcd0c61d0fefa0d463c046011698acf9

LGTM.

Reviewed-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


> ---
>  gdb/linux-nat.c | 7 +++++++
>  gdb/linux-nat.h | 2 ++
>  2 files changed, 9 insertions(+)
>
> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
> index f3d02b740e8..5fadc82deb0 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -4468,6 +4468,13 @@ linux_nat_target::thread_events (int enable)
>    report_thread_events = enable;
>  }
>  
> +bool
> +linux_nat_target::supports_set_thread_options (gdb_thread_options options)
> +{
> +  constexpr gdb_thread_options supported_options = GDB_THREAD_OPTION_CLONE;
> +  return ((options & supported_options) == options);
> +}
> +
>  linux_nat_target::linux_nat_target ()
>  {
>    /* We don't change the stratum; this target will sit at
> diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
> index 3ed25cc5ba4..258041b8271 100644
> --- a/gdb/linux-nat.h
> +++ b/gdb/linux-nat.h
> @@ -82,6 +82,8 @@ class linux_nat_target : public inf_ptrace_target
>  
>    void thread_events (int) override;
>  
> +  bool supports_set_thread_options (gdb_thread_options options) override;
> +
>    bool can_async_p () override;
>  
>    bool supports_non_stop () override;
> -- 
> 2.36.0
  

Patch

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index f3d02b740e8..5fadc82deb0 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4468,6 +4468,13 @@  linux_nat_target::thread_events (int enable)
   report_thread_events = enable;
 }
 
+bool
+linux_nat_target::supports_set_thread_options (gdb_thread_options options)
+{
+  constexpr gdb_thread_options supported_options = GDB_THREAD_OPTION_CLONE;
+  return ((options & supported_options) == options);
+}
+
 linux_nat_target::linux_nat_target ()
 {
   /* We don't change the stratum; this target will sit at
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 3ed25cc5ba4..258041b8271 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -82,6 +82,8 @@  class linux_nat_target : public inf_ptrace_target
 
   void thread_events (int) override;
 
+  bool supports_set_thread_options (gdb_thread_options options) override;
+
   bool can_async_p () override;
 
   bool supports_non_stop () override;