binutils-gdb/gdb/nat/aarch64-linux.h

130 lines
3.0 KiB
C
Raw Normal View History

/* Copyright (C) 2009-2017 Free Software Foundation, Inc.
Contributed by ARM Ltd.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef AARCH64_LINUX_H
#define AARCH64_LINUX_H 1
#include <signal.h>
aarch64 multi-arch (part 3): get thread area With the kernle fix <http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/356511.html>, aarch64 GDB is able to read the base of thread area of 32-bit arm program through NT_ARM_TLS. This patch is to teach both GDB and GDBserver to read the base of thread area correctly in the multi-arch case. A new function aarch64_ps_get_thread_area is added, and is shared between GDB and GDBserver. With this patch applied, the following fails in multi-arch testing (GDB is aarch64 but the test cases are arm) are fixed, -FAIL: gdb.threads/tls-nodebug.exp: thread local storage -FAIL: gdb.threads/tls-shared.exp: print thread local storage variable -FAIL: gdb.threads/tls-so_extern.exp: print thread local storage variable -FAIL: gdb.threads/tls-var.exp: print tls_var -FAIL: gdb.threads/tls.exp: first thread local storage -FAIL: gdb.threads/tls.exp: first another thread local storage -FAIL: gdb.threads/tls.exp: p a_thread_local -FAIL: gdb.threads/tls.exp: p file2_thread_local -FAIL: gdb.threads/tls.exp: p a_thread_local second time gdb: 2015-09-18 Yao Qi <yao.qi@linaro.org> * nat/aarch64-linux.c: Include elf/common.h, nat/gdb_ptrace.h, asm/ptrace.h and sys/uio.h. (aarch64_ps_get_thread_area): New function. * nat/aarch64-linux.h: Include gdb_proc_service.h. (aarch64_ps_get_thread_area): Declare. * aarch64-linux-nat.c (ps_get_thread_area): Call aarch64_ps_get_thread_area. gdb/gdbserver: 2015-09-18 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c: Don't include sys/uio.h. (ps_get_thread_area): Call aarch64_ps_get_thread_area.
2015-09-18 14:59:42 +02:00
/* Defines ps_err_e, struct ps_prochandle. */
#include "gdb_proc_service.h"
typedef int compat_int_t;
typedef unsigned int compat_uptr_t;
typedef int compat_time_t;
typedef int compat_timer_t;
typedef int compat_clock_t;
struct compat_timeval
{
compat_time_t tv_sec;
int tv_usec;
};
typedef union compat_sigval
{
compat_int_t sival_int;
compat_uptr_t sival_ptr;
} compat_sigval_t;
typedef struct compat_siginfo
{
int si_signo;
int si_errno;
int si_code;
union
{
int _pad[((128 / sizeof (int)) - 3)];
/* kill() */
struct
{
unsigned int _pid;
unsigned int _uid;
} _kill;
/* POSIX.1b timers */
struct
{
compat_timer_t _tid;
int _overrun;
compat_sigval_t _sigval;
} _timer;
/* POSIX.1b signals */
struct
{
unsigned int _pid;
unsigned int _uid;
compat_sigval_t _sigval;
} _rt;
/* SIGCHLD */
struct
{
unsigned int _pid;
unsigned int _uid;
int _status;
compat_clock_t _utime;
compat_clock_t _stime;
} _sigchld;
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
struct
{
unsigned int _addr;
} _sigfault;
/* SIGPOLL */
struct
{
int _band;
int _fd;
} _sigpoll;
} _sifields;
} compat_siginfo_t;
#define cpt_si_pid _sifields._kill._pid
#define cpt_si_uid _sifields._kill._uid
#define cpt_si_timerid _sifields._timer._tid
#define cpt_si_overrun _sifields._timer._overrun
#define cpt_si_status _sifields._sigchld._status
#define cpt_si_utime _sifields._sigchld._utime
#define cpt_si_stime _sifields._sigchld._stime
#define cpt_si_ptr _sifields._rt._sigval.sival_ptr
#define cpt_si_addr _sifields._sigfault._addr
#define cpt_si_band _sifields._sigpoll._band
#define cpt_si_fd _sifields._sigpoll._fd
void aarch64_siginfo_from_compat_siginfo (siginfo_t *to,
compat_siginfo_t *from);
void aarch64_compat_siginfo_from_siginfo (compat_siginfo_t *to,
siginfo_t *from);
void aarch64_linux_prepare_to_resume (struct lwp_info *lwp);
void aarch64_linux_new_thread (struct lwp_info *lwp);
Sync proc_service definition with GLIBC GLIBC BZ#20311 [1] proc_service.h install patch also remove 'const' attributes from ps_get_thread_area and comment #15 discuss why to remove the const attribute (basically since it a callback with the struct ps_prochandle owned by the client it should be able to modify it if it the case). On default build this is not the issue and current g++ does not trigger any issue with this mismatch declaration. However, on some bootstrap build configuration where gdbserver is build with gcc instead this triggers: error: conflicting types for 'ps_get_thread_area' This patch fixes it by syncing the declaration with GLIBC. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=20311 gdb/ChangeLog: 2016-08-25 Adhemerval Zanella <adhemerval.zanella@linaro.org> * aarch64-linux-nat.c (ps_get_thread_area): Remove const from struct ps_prochandle. * amd64-linux-nat.c (ps_get_thread_area): Likewise. * arm-linux-nat.c (ps_get_thread_area): Likewise. * gdb_proc_service.h (ps_get_thread_area): Likewise. * i386-linux-nat.c (ps_get_thread_area): Likewise. * m68klinux-nat.c (ps_get_thread_area): Likewise. * mips-linux-nat.c (ps_get_thread_area): Likewise. * nat/aarch64-linux.c (aarch64_ps_get_thread_area): Likewise. * nat/aarch64-linux.h (aarch64_ps_get_thread_area): Likewise. * xtensa-linux-nat.c (ps_get_thread_area): Likewise. gdb/gdbserver/ChangeLog: 2016-08-25 Adhemerval Zanella <adhemerval.zanella@linaro.org> PR server/20491 * gdb_proc_service.h (ps_get_thread_area): Remove const from struct ps_prochandle. * linux-aarch64-low.c (ps_get_thread_area): Likewise. * linux-arm-low.c (ps_get_thread_area): Likewise. * linux-crisv32-low.c (ps_get_thread_area): Likewise. * linux-m68k-low.c (ps_get_thread_area): Likewise. * linux-mips-low.c (ps_get_thread_area): Likewise. * linux-nios2-low.c (ps_get_thread_area): Likewise. * linux-tic6x-low.c (ps_get_thread_area): Likewise. * linux-x86-low.c (ps_get_thread_area): Likewise. * linux-xtensa-low.c (ps_get_thread_area): Likewise.
2016-08-25 09:42:03 +02:00
ps_err_e aarch64_ps_get_thread_area (struct ps_prochandle *ph,
aarch64 multi-arch (part 3): get thread area With the kernle fix <http://lists.infradead.org/pipermail/linux-arm-kernel/2015-July/356511.html>, aarch64 GDB is able to read the base of thread area of 32-bit arm program through NT_ARM_TLS. This patch is to teach both GDB and GDBserver to read the base of thread area correctly in the multi-arch case. A new function aarch64_ps_get_thread_area is added, and is shared between GDB and GDBserver. With this patch applied, the following fails in multi-arch testing (GDB is aarch64 but the test cases are arm) are fixed, -FAIL: gdb.threads/tls-nodebug.exp: thread local storage -FAIL: gdb.threads/tls-shared.exp: print thread local storage variable -FAIL: gdb.threads/tls-so_extern.exp: print thread local storage variable -FAIL: gdb.threads/tls-var.exp: print tls_var -FAIL: gdb.threads/tls.exp: first thread local storage -FAIL: gdb.threads/tls.exp: first another thread local storage -FAIL: gdb.threads/tls.exp: p a_thread_local -FAIL: gdb.threads/tls.exp: p file2_thread_local -FAIL: gdb.threads/tls.exp: p a_thread_local second time gdb: 2015-09-18 Yao Qi <yao.qi@linaro.org> * nat/aarch64-linux.c: Include elf/common.h, nat/gdb_ptrace.h, asm/ptrace.h and sys/uio.h. (aarch64_ps_get_thread_area): New function. * nat/aarch64-linux.h: Include gdb_proc_service.h. (aarch64_ps_get_thread_area): Declare. * aarch64-linux-nat.c (ps_get_thread_area): Call aarch64_ps_get_thread_area. gdb/gdbserver: 2015-09-18 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c: Don't include sys/uio.h. (ps_get_thread_area): Call aarch64_ps_get_thread_area.
2015-09-18 14:59:42 +02:00
lwpid_t lwpid, int idx, void **base,
int is_64bit_p);
#endif /* AARCH64_LINUX_H */