From: Tom Tromey Date: Wed, 19 Feb 2025 15:55:37 +0000 (-0700) Subject: Small get_tib_address cleanups X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=904d3768c88a6591204969826f47d706f6da504a;p=thirdparty%2Fbinutils-gdb.git Small get_tib_address cleanups I noticed a non-bool-like use of target_get_tib_address in windows-tdep.c. After fixing this I thought it would be good to document the target method; and this also lead to some non-bool-like commentary in remote.c. This patch fixes all of these nits. Approved-By: Simon Marchi --- diff --git a/gdb/remote.c b/gdb/remote.c index 46359400fb2..9dfc372fc41 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -12473,9 +12473,6 @@ remote_target::get_thread_local_address (ptid_t ptid, CORE_ADDR lm, return 0; } -/* Provide thread local base, i.e. Thread Information Block address. - Returns 1 if ptid is found and thread_local_base is non zero. */ - bool remote_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr) { diff --git a/gdb/target.h b/gdb/target.h index 5b45f152b51..d46b288fd16 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1162,8 +1162,12 @@ struct target_ops CORE_ADDR memaddr, ULONGEST size) TARGET_DEFAULT_FUNC (default_verify_memory); - /* Return the address of the start of the Thread Information Block - a Windows OS specific feature. */ + /* Set *ADDR to the address of the start of the Thread Information + Block (TIB) for thread PTID. Return true on success and false + otherwise. + + ADDR may be nullptr, in which case the checks will be done but + the result will be discarded. */ virtual bool get_tib_address (ptid_t ptid, CORE_ADDR *addr) TARGET_DEFAULT_NORETURN (tcomplain ()); @@ -2338,6 +2342,8 @@ extern void target_set_trace_buffer_size (LONGEST val); extern bool target_set_trace_notes (const char *user, const char *notes, const char *stopnotes); +/* A wrapper that calls get_tib_address on the top target of the + current inferior. */ extern bool target_get_tib_address (ptid_t ptid, CORE_ADDR *addr); extern void target_set_permissions (); diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index a5243dc8715..1302b25ed1b 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -478,7 +478,7 @@ display_one_tib (ptid_t ptid) tib = (gdb_byte *) alloca (tib_size); - if (target_get_tib_address (ptid, &thread_local_base) == 0) + if (!target_get_tib_address (ptid, &thread_local_base)) { gdb_printf (_("Unable to get thread local base for %s\n"), target_pid_to_str (ptid).c_str ());