gdbserver: Add PID parameter to linux_get_auxv and linux_get_hwcap

This patch doesn't change gdbserver behaviour, but after later changes are
made it avoids a null pointer dereference when HWCAP needs to be obtained
for a specific process while current_thread is nullptr.

Fixing linux_read_auxv, linux_get_hwcap and linux_get_hwcap2 to take a PID
parameter seems more correct than setting current_thread in one particular
code path.

Changes are propagated to allow passing the new parameter through the call
chain.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Thiago Jung Bauermann
2022-08-18 18:21:18 +00:00
parent cbd02f9fa5
commit 43e5fbd8b7
11 changed files with 36 additions and 37 deletions

View File

@@ -581,11 +581,9 @@ netbsd_read_auxv(pid_t pid, void *offs, void *addr, size_t len)
to debugger memory starting at MYADDR. */
int
netbsd_process_target::read_auxv (CORE_ADDR offset,
netbsd_process_target::read_auxv (int pid, CORE_ADDR offset,
unsigned char *myaddr, unsigned int len)
{
pid_t pid = pid_of (current_thread);
return netbsd_read_auxv (pid, (void *) (intptr_t) offset, myaddr, len);
}