aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-09-17 07:46:03 -0600
committerTom Tromey <tromey@adacore.com>2021-09-23 09:30:54 -0600
commitc80e29dba968beca5eee7210d2030d27fe7790c3 (patch)
treeb6e08f09ecd225efa78aae2c6966994413a21b5e
parent96bbe3ef9653e23a17b2315627e0cab441815f2d (diff)
downloadgdb-c80e29dba968beca5eee7210d2030d27fe7790c3.zip
gdb-c80e29dba968beca5eee7210d2030d27fe7790c3.tar.gz
gdb-c80e29dba968beca5eee7210d2030d27fe7790c3.tar.bz2
Change get_ada_task_ptid parameter type
get_ada_task_ptid currently takes a 'long' as its 'thread' parameter type. However, on some platforms this is actually a pointer, and using 'long' can sometimes end up with the value being sign-extended. This sign extension can cause problems later, if the tid is then later used as an address again. This patch changes the parameter type to ULONGEST and updates all the uses. This approach preserves sign extension on the targets where it is apparently intended, while avoiding it on others. Co-Authored-By: John Baldwin <jhb@FreeBSD.org>
-rw-r--r--gdb/ada-tasks.c2
-rw-r--r--gdb/aix-thread.c4
-rw-r--r--gdb/darwin-nat.c2
-rw-r--r--gdb/darwin-nat.h2
-rw-r--r--gdb/fbsd-nat.c4
-rw-r--r--gdb/linux-thread-db.c4
-rw-r--r--gdb/ravenscar-thread.c4
-rw-r--r--gdb/remote.c4
-rw-r--r--gdb/sol-thread.c6
-rw-r--r--gdb/target-delegates.c12
-rw-r--r--gdb/target.c6
-rw-r--r--gdb/target.h4
-rw-r--r--gdb/windows-nat.c4
13 files changed, 29 insertions, 29 deletions
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index bef26e8..9a5bcc6 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -600,7 +600,7 @@ ada_get_tcb_types_info (void)
static ptid_t
ptid_from_atcb_common (struct value *common_value)
{
- long thread = 0;
+ ULONGEST thread;
CORE_ADDR lwp = 0;
struct value *ll_value;
ptid_t ptid;
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 0ab4d7b..0464901 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -144,7 +144,7 @@ public:
const char *extra_thread_info (struct thread_info *) override;
- ptid_t get_ada_task_ptid (long lwp, long thread) override;
+ ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
};
static aix_thread_target aix_thread_ops;
@@ -1825,7 +1825,7 @@ aix_thread_target::extra_thread_info (struct thread_info *thread)
}
ptid_t
-aix_thread_target::get_ada_task_ptid (long lwp, long thread)
+aix_thread_target::get_ada_task_ptid (long lwp, ULONGEST thread)
{
return ptid_t (inferior_ptid.pid (), 0, thread);
}
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index a679079..84558bf 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -2376,7 +2376,7 @@ darwin_nat_target::pid_to_exec_file (int pid)
}
ptid_t
-darwin_nat_target::get_ada_task_ptid (long lwp, long thread)
+darwin_nat_target::get_ada_task_ptid (long lwp, ULONGEST thread)
{
struct inferior *inf = current_inferior ();
darwin_inferior *priv = get_darwin_inferior (inf);
diff --git a/gdb/darwin-nat.h b/gdb/darwin-nat.h
index a288ed4..0e5951d 100644
--- a/gdb/darwin-nat.h
+++ b/gdb/darwin-nat.h
@@ -111,7 +111,7 @@ class darwin_nat_target : public inf_child_target
bool supports_multi_process () override;
- ptid_t get_ada_task_ptid (long lwp, long thread) override;
+ ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
private:
ptid_t wait_1 (ptid_t, struct target_waitstatus *);
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 181d344..1323626 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -1045,8 +1045,8 @@ fbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
return;
#endif
- fbsd_lwp_debug_printf ("ptid (%d, %ld, %ld)", ptid.pid (), ptid.lwp (),
- ptid.tid ());
+ fbsd_lwp_debug_printf ("ptid (%d, %ld, %s)", ptid.pid (), ptid.lwp (),
+ pulongest (ptid.tid ()));
if (ptid.lwp_p ())
{
/* If ptid is a specific LWP, suspend all other LWPs in the process. */
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 3929589..bfb3bd6 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -102,7 +102,7 @@ public:
CORE_ADDR load_module_addr,
CORE_ADDR offset) override;
const char *extra_thread_info (struct thread_info *) override;
- ptid_t get_ada_task_ptid (long lwp, long thread) override;
+ ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
thread_info *thread_handle_to_thread_info (const gdb_byte *thread_handle,
int handle_len,
@@ -1839,7 +1839,7 @@ thread_db_target::get_thread_local_address (ptid_t ptid,
/* Implement the to_get_ada_task_ptid target method for this target. */
ptid_t
-thread_db_target::get_ada_task_ptid (long lwp, long thread)
+thread_db_target::get_ada_task_ptid (long lwp, ULONGEST thread)
{
/* NPTL uses a 1:1 model, so the LWP id suffices. */
return ptid_t (inferior_ptid.pid (), lwp);
diff --git a/gdb/ravenscar-thread.c b/gdb/ravenscar-thread.c
index 6cc583c..85f934b 100644
--- a/gdb/ravenscar-thread.c
+++ b/gdb/ravenscar-thread.c
@@ -118,7 +118,7 @@ struct ravenscar_thread_target final : public target_ops
std::string pid_to_str (ptid_t) override;
- ptid_t get_ada_task_ptid (long lwp, long thread) override;
+ ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
struct btrace_target_info *enable_btrace (ptid_t ptid,
const struct btrace_config *conf)
@@ -682,7 +682,7 @@ ravenscar_inferior_created (inferior *inf)
}
ptid_t
-ravenscar_thread_target::get_ada_task_ptid (long lwp, long thread)
+ravenscar_thread_target::get_ada_task_ptid (long lwp, ULONGEST thread)
{
return ptid_t (m_base_ptid.pid (), 0, thread);
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 3ece443..0dfe36a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -493,7 +493,7 @@ public:
const char *extra_thread_info (struct thread_info *) override;
- ptid_t get_ada_task_ptid (long lwp, long thread) override;
+ ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
thread_info *thread_handle_to_thread_info (const gdb_byte *thread_handle,
int handle_len,
@@ -4136,7 +4136,7 @@ remote_target::static_tracepoint_markers_by_strid (const char *strid)
/* Implement the to_get_ada_task_ptid function for the remote targets. */
ptid_t
-remote_target::get_ada_task_ptid (long lwp, long thread)
+remote_target::get_ada_task_ptid (long lwp, ULONGEST thread)
{
return ptid_t (inferior_ptid.pid (), lwp);
}
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 18eacf1..513d030 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -88,7 +88,7 @@ public:
void resume (ptid_t, int, enum gdb_signal) override;
void mourn_inferior () override;
std::string pid_to_str (ptid_t) override;
- ptid_t get_ada_task_ptid (long lwp, long thread) override;
+ ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
void fetch_registers (struct regcache *, int) override;
void store_registers (struct regcache *, int) override;
@@ -1120,7 +1120,7 @@ info_solthreads (const char *args, int from_tty)
static int
thread_db_find_thread_from_tid (struct thread_info *thread, void *data)
{
- long *tid = (long *) data;
+ ULONGEST *tid = (ULONGEST *) data;
if (thread->ptid.tid () == *tid)
return 1;
@@ -1129,7 +1129,7 @@ thread_db_find_thread_from_tid (struct thread_info *thread, void *data)
}
ptid_t
-sol_thread_target::get_ada_task_ptid (long lwp, long thread)
+sol_thread_target::get_ada_task_ptid (long lwp, ULONGEST thread)
{
struct thread_info *thread_info =
iterate_over_threads (thread_db_find_thread_from_tid, &thread);
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 3fd2854..fb9c78a 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -99,7 +99,7 @@ struct dummy_target : public target_ops
void flash_erase (ULONGEST arg0, LONGEST arg1) override;
void flash_done () override;
const struct target_desc *read_description () override;
- ptid_t get_ada_task_ptid (long arg0, long arg1) override;
+ ptid_t get_ada_task_ptid (long arg0, ULONGEST arg1) override;
int auxv_parse (gdb_byte **arg0, gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3) override;
int search_memory (CORE_ADDR arg0, ULONGEST arg1, const gdb_byte *arg2, ULONGEST arg3, CORE_ADDR *arg4) override;
bool can_execute_reverse () override;
@@ -274,7 +274,7 @@ struct debug_target : public target_ops
void flash_erase (ULONGEST arg0, LONGEST arg1) override;
void flash_done () override;
const struct target_desc *read_description () override;
- ptid_t get_ada_task_ptid (long arg0, long arg1) override;
+ ptid_t get_ada_task_ptid (long arg0, ULONGEST arg1) override;
int auxv_parse (gdb_byte **arg0, gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3) override;
int search_memory (CORE_ADDR arg0, ULONGEST arg1, const gdb_byte *arg2, ULONGEST arg3, CORE_ADDR *arg4) override;
bool can_execute_reverse () override;
@@ -2598,19 +2598,19 @@ debug_target::read_description ()
}
ptid_t
-target_ops::get_ada_task_ptid (long arg0, long arg1)
+target_ops::get_ada_task_ptid (long arg0, ULONGEST arg1)
{
return this->beneath ()->get_ada_task_ptid (arg0, arg1);
}
ptid_t
-dummy_target::get_ada_task_ptid (long arg0, long arg1)
+dummy_target::get_ada_task_ptid (long arg0, ULONGEST arg1)
{
return default_get_ada_task_ptid (this, arg0, arg1);
}
ptid_t
-debug_target::get_ada_task_ptid (long arg0, long arg1)
+debug_target::get_ada_task_ptid (long arg0, ULONGEST arg1)
{
ptid_t result;
fprintf_unfiltered (gdb_stdlog, "-> %s->get_ada_task_ptid (...)\n", this->beneath ()->shortname ());
@@ -2618,7 +2618,7 @@ debug_target::get_ada_task_ptid (long arg0, long arg1)
fprintf_unfiltered (gdb_stdlog, "<- %s->get_ada_task_ptid (", this->beneath ()->shortname ());
target_debug_print_long (arg0);
fputs_unfiltered (", ", gdb_stdlog);
- target_debug_print_long (arg1);
+ target_debug_print_ULONGEST (arg1);
fputs_unfiltered (") = ", gdb_stdlog);
target_debug_print_ptid_t (result);
fputs_unfiltered ("\n", gdb_stdlog);
diff --git a/gdb/target.c b/gdb/target.c
index d1c1bf5..2cb587d 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -67,7 +67,7 @@ static int default_region_ok_for_hw_watchpoint (struct target_ops *,
static void default_rcmd (struct target_ops *, const char *, struct ui_file *);
static ptid_t default_get_ada_task_ptid (struct target_ops *self,
- long lwp, long tid);
+ long lwp, ULONGEST tid);
static void default_mourn_inferior (struct target_ops *self);
@@ -595,7 +595,7 @@ target_can_execute_reverse ()
}
ptid_t
-target_get_ada_task_ptid (long lwp, long tid)
+target_get_ada_task_ptid (long lwp, ULONGEST tid)
{
return current_inferior ()->top_target ()->get_ada_task_ptid (lwp, tid);
}
@@ -1133,7 +1133,7 @@ default_terminal_info (struct target_ops *self, const char *args, int from_tty)
inferior_ptid. */
static ptid_t
-default_get_ada_task_ptid (struct target_ops *self, long lwp, long tid)
+default_get_ada_task_ptid (struct target_ops *self, long lwp, ULONGEST tid)
{
return ptid_t (inferior_ptid.pid (), lwp, tid);
}
diff --git a/gdb/target.h b/gdb/target.h
index 57afebe..61febdb 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -856,7 +856,7 @@ struct target_ops
based on LWP and THREAD. These values are extracted from the
task Private_Data section of the Ada Task Control Block, and
their interpretation depends on the target. */
- virtual ptid_t get_ada_task_ptid (long lwp, long thread)
+ virtual ptid_t get_ada_task_ptid (long lwp, ULONGEST thread)
TARGET_DEFAULT_FUNC (default_get_ada_task_ptid);
/* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
@@ -2141,7 +2141,7 @@ extern bool target_can_execute_reverse ();
extern const struct target_desc *target_read_description (struct target_ops *);
-extern ptid_t target_get_ada_task_ptid (long lwp, long tid);
+extern ptid_t target_get_ada_task_ptid (long lwp, ULONGEST tid);
/* Main entry point for searching memory. */
extern int target_search_memory (CORE_ADDR start_addr,
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 0c2d55e..a052efe 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -277,7 +277,7 @@ struct windows_nat_target final : public x86_nat_target<inf_child_target>
char *pid_to_exec_file (int pid) override;
- ptid_t get_ada_task_ptid (long lwp, long thread) override;
+ ptid_t get_ada_task_ptid (long lwp, ULONGEST thread) override;
bool get_tib_address (ptid_t ptid, CORE_ADDR *addr) override;
@@ -3082,7 +3082,7 @@ windows_nat_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
}
ptid_t
-windows_nat_target::get_ada_task_ptid (long lwp, long thread)
+windows_nat_target::get_ada_task_ptid (long lwp, ULONGEST thread)
{
return ptid_t (inferior_ptid.pid (), lwp, 0);
}