From d89fa914ad6f10cf2827df9b3b86da1a7d9ddfd8 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Wed, 5 Aug 2015 08:41:19 +0100 Subject: Remove get_thread_id This patch removes get_thread_id from aarch64-linux-nat.c, arm-linux-nat.c and xtensa-linux-nat.c. get_thread_id was added in this commit below in 2000, 41c49b06c471443d3baf2eaa2463a315f9b5edca https://sourceware.org/ml/gdb-patches/2000-04/msg00398.html which predates the ptid_t stuff added into GDB. Nowadays, lwpid of inferior_ptid is only zero when the inferior is created (in fork-child.c:fork_inferior) and its lwpid will be set after linux_nat_wait_1 gets the first event. After that, lwpid of inferior_ptid is not zero for linux-nat target, then we can use ptid_get_lwp, so this function isn't needed anymore. Even when GDB attaches to a process, the lwp of inferior_ptid isn't zero, see linux-nat.c:linux_nat_attach, /* The ptrace base target adds the main thread with (pid,0,0) format. Decorate it with lwp info. */ ptid = ptid_build (ptid_get_pid (inferior_ptid), ptid_get_pid (inferior_ptid), 0); Note that linux_nat_xfer_partial shifts lwpid to pid for inferior_ptid temperately for calling linux_ops->to_xfer_partial, but all the affected functions in this patch are not called in linux_ops->to_xfer_partial. I think we can safely remove get_thread_id for all linux native targets. Regression tested on arm-linux and aarch64-linux. Unable to build native GDB and test it on xtensa-linux. gdb: 2015-08-05 Yao Qi * aarch64-linux-nat.c (get_thread_id): Remove. (debug_reg_change_callback): Call ptid_get_lwp instead of get_thread_id. (fetch_gregs_from_thread): Likewise. (store_gregs_to_thread): Likewise. (fetch_fpregs_from_thread): Likewise. (store_fpregs_to_thread): Likewise. (aarch64_linux_get_debug_reg_capacity): Likewise. * arm-linux-nat.c (get_thread_id): Remove. (GET_THREAD_ID): Update macro to use ptid_get_lwp. * xtensa-linux-nat.c (get_thread_id): Remove. (GET_THREAD_ID): Update macro to use ptid_get_lwp. * arm-linux-nat.c (get_thread_id): Remove. (GET_THREAD_ID): Remove. (fetch_fpregs): Call ptid_get_lwp instead of GET_THREAD_ID. (store_fpregs, fetch_regs, store_regs): Likewise. (fetch_wmmx_regs, store_wmmx_regs): Likewise. (fetch_vfp_regs, store_vfp_regs): Likewise. (arm_linux_read_description): Likewise. (arm_linux_get_hwbp_cap): Likewise. * xtensa-linux-nat.c (get_thread_id): Remove. (GET_THREAD_ID): Remove. (fetch_gregs, store_gregs): Call ptid_get_lwp instead of GET_THREAD_ID. --- gdb/xtensa-linux-nat.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'gdb/xtensa-linux-nat.c') diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c index 7f530ce..77ad3e0 100644 --- a/gdb/xtensa-linux-nat.c +++ b/gdb/xtensa-linux-nat.c @@ -42,16 +42,6 @@ hardware-specific overlays. */ #include "xtensa-xtregs.c" -static int -get_thread_id (ptid_t ptid) -{ - int tid = ptid_get_lwp (ptid); - if (0 == tid) - tid = ptid_get_pid (ptid); - return tid; -} -#define GET_THREAD_ID(PTID) get_thread_id (PTID) - void fill_gregset (const struct regcache *regcache, gdb_gregset_t *gregsetp, int regnum) @@ -181,7 +171,7 @@ supply_fpregset (struct regcache *regcache, static void fetch_gregs (struct regcache *regcache, int regnum) { - int tid = GET_THREAD_ID (inferior_ptid); + int tid = ptid_get_lwp (inferior_ptid); const gdb_gregset_t regs; int areg; @@ -200,7 +190,7 @@ fetch_gregs (struct regcache *regcache, int regnum) static void store_gregs (struct regcache *regcache, int regnum) { - int tid = GET_THREAD_ID (inferior_ptid); + int tid = ptid_get_lwp (inferior_ptid); gdb_gregset_t regs; int areg; @@ -228,7 +218,7 @@ static int xtreg_high; static void fetch_xtregs (struct regcache *regcache, int regnum) { - int tid = GET_THREAD_ID (inferior_ptid); + int tid = ptid_get_lwp (inferior_ptid); const xtensa_regtable_t *ptr; char xtregs [XTENSA_ELF_XTREG_SIZE]; @@ -244,7 +234,7 @@ fetch_xtregs (struct regcache *regcache, int regnum) static void store_xtregs (struct regcache *regcache, int regnum) { - int tid = GET_THREAD_ID (inferior_ptid); + int tid = ptid_get_lwp (inferior_ptid); const xtensa_regtable_t *ptr; char xtregs [XTENSA_ELF_XTREG_SIZE]; -- cgit v1.1