Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VDSO support to libunwind , port the patch from https://sourcewar… #728

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/unw_get_proc_name_by_ip.man
bregma marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" *********************************** start of \input{common.tex}
.\" *********************************** end of \input{common.tex}
'\" t
.\" Manual page created with latex2man on Tue Aug 29 12:09:48 2023
.\" Manual page created with latex2man on Fri Feb 23 11:27:29 2024
.\" NOTE: This file is generated, DO NOT EDIT.
.de Vb
.ft CW
Expand All @@ -12,7 +12,7 @@

.fi
..
.TH "UNW\\_GET\\_PROC\\_NAME\\_BY\\_IP" "3libunwind" "29 August 2023" "Programming Library " "Programming Library "
.TH "UNW\\_GET\\_PROC\\_NAME\\_BY\\_IP" "3libunwind" "23 February 2024" "Programming Library " "Programming Library "
.SH NAME
unw_get_proc_name_by_ip
\-\- get procedure name
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-aarch64/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (unw_context_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
- void *arg);
bregma marked this conversation as resolved.
Show resolved Hide resolved
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-arm/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-hppa/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-ia64/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,10 @@ extern void tdep_put_unwind_info (unw_addr_space_t as,
unw_proc_info_t *pi, void *arg);
extern void *tdep_uc_addr (ucontext_t *uc, unw_regnum_t regnum,
uint8_t *nat_bitnr);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-loongarch64/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-mips/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-ppc32/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_proc_info_t * pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (ucontext_t * uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t * valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-ppc64/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_proc_info_t * pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (ucontext_t * uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t * valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-riscv/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-s390x/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen),
void *arg;
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-sh/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (unw_tdep_context_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
bregma marked this conversation as resolved.
Show resolved Hide resolved
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-x86/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
5 changes: 3 additions & 2 deletions include/tdep-x86_64/libunwind_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,10 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
unw_dyn_info_t *di, unw_proc_info_t *pi,
int need_unwind_info, void *arg);
extern void *x86_64_r_uc_addr (ucontext_t *uc, int reg);
extern int tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
extern int tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen);
char *path, size_t pathlen,
void *arg);
extern void tdep_get_exe_image_path (char *path);
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
unw_word_t *valp, int write);
Expand Down
4 changes: 2 additions & 2 deletions src/aarch64/Ginit.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ get_static_proc_name (unw_addr_space_t as, unw_word_t ip,
char *buf, size_t buf_len, unw_word_t *offp,
void *arg)
{
return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp);
return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp,arg);
bregma marked this conversation as resolved.
Show resolved Hide resolved
}

static unw_word_t empty_ptrauth_mask(unw_addr_space_t addr_space_unused, void *as_arg_unused)
Expand All @@ -228,7 +228,7 @@ static unw_word_t empty_ptrauth_mask(unw_addr_space_t addr_space_unused, void *a
static int
get_static_elf_filename (unw_addr_space_t as, unw_word_t ip, char *buf, size_t buf_len, unw_word_t *offp, void *arg)
{
return _Uelf64_get_elf_filename(as, getpid(), ip, buf, buf_len, offp);
return _Uelf64_get_elf_filename(as, getpid(), ip, buf, buf_len, offp,arg);
}

HIDDEN void
Expand Down
2 changes: 1 addition & 1 deletion src/arm/Ginit.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ get_static_proc_name (unw_addr_space_t as, unw_word_t ip,
char *buf, size_t buf_len, unw_word_t *offp,
void *arg)
{
return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp);
return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp,arg);
}

static int
Expand Down
12 changes: 6 additions & 6 deletions src/elfxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,14 @@ elf_w (get_proc_name_in_image) (unw_addr_space_t as, struct elf_image *ei,

HIDDEN int
elf_w (get_proc_name) (unw_addr_space_t as, pid_t pid, unw_word_t ip,
char *buf, size_t buf_len, unw_word_t *offp)
char *buf, size_t buf_len, unw_word_t *offp, void *arg)
{
unsigned long segbase, mapoff;
struct elf_image ei;
int ret;
char file[PATH_MAX];

ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff, file, PATH_MAX);
ret = tdep_get_elf_image (as, &ei, pid, ip, &segbase, &mapoff, file, PATH_MAX,arg);
if (ret < 0)
return ret;

Expand Down Expand Up @@ -687,14 +687,14 @@ elf_w (get_proc_ip_range_in_image) (unw_addr_space_t as, struct elf_image *ei,

HIDDEN int
elf_w (get_proc_ip_range) (unw_addr_space_t as, pid_t pid, unw_word_t ip,
unw_word_t *start, unw_word_t *end)
unw_word_t *start, unw_word_t *end, void *arg)
{
unsigned long segbase, mapoff;
struct elf_image ei;
int ret;
char file[PATH_MAX];

ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff, file, PATH_MAX);
ret = tdep_get_elf_image (as, &ei, pid, ip, &segbase, &mapoff, file, PATH_MAX, arg);
if (ret < 0)
return ret;

Expand All @@ -712,13 +712,13 @@ elf_w (get_proc_ip_range) (unw_addr_space_t as, pid_t pid, unw_word_t ip,

HIDDEN int
elf_w (get_elf_filename) (unw_addr_space_t as, pid_t pid, unw_word_t ip,
char *buf, size_t buf_len, unw_word_t *offp)
char *buf, size_t buf_len, unw_word_t *offp, void *arg)
{
unsigned long segbase, mapoff;
int ret = UNW_ESUCCESS;

// use NULL to no map elf image
ret = tdep_get_elf_image (NULL, pid, ip, &segbase, &mapoff, buf, buf_len);
ret = tdep_get_elf_image (as, NULL, pid, ip, &segbase, &mapoff, buf, buf_len, arg);
if (ret < 0)
return ret;

Expand Down
6 changes: 3 additions & 3 deletions src/elfxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
extern int elf_w (get_proc_name) (unw_addr_space_t as,
pid_t pid, unw_word_t ip,
char *buf, size_t len,
unw_word_t *offp);
unw_word_t *offp, void *arg);

extern int elf_w (get_proc_name_in_image) (unw_addr_space_t as,
struct elf_image *ei,
Expand All @@ -55,14 +55,14 @@ extern int elf_w (get_proc_name_in_image) (unw_addr_space_t as,

extern int elf_w (get_proc_ip_range) (unw_addr_space_t as,
pid_t pid, unw_word_t ip,
unw_word_t *start, unw_word_t *end);
unw_word_t *start, unw_word_t *end, void *arg);

extern int elf_w (get_proc_ip_range_in_image) (unw_addr_space_t as, struct elf_image *ei,
unsigned long segbase, unw_word_t ip,
unw_word_t *start, unw_word_t *end);

extern int elf_w (get_elf_filename) (unw_addr_space_t as, pid_t pid, unw_word_t ip,
char *buf, size_t buf_len, unw_word_t *offp);
char *buf, size_t buf_len, unw_word_t *offp, void *arg);

extern Elf_W (Shdr)* elf_w (find_section) (const struct elf_image *ei, const char* secname);
extern int elf_w (load_debuginfo) (const char* file, struct elf_image *ei, int is_local);
Expand Down
2 changes: 1 addition & 1 deletion src/hppa/Ginit.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ get_static_proc_name (unw_addr_space_t as, unw_word_t ip,
char *buf, size_t buf_len, unw_word_t *offp,
void *arg)
{
return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp);
return _Uelf32_get_proc_name (as, getpid (), ip, buf, buf_len, offp, arg);
}

static int
Expand Down
2 changes: 1 addition & 1 deletion src/ia64/Ginit.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ get_static_proc_name (unw_addr_space_t as, unw_word_t ip,
char *buf, size_t buf_len, unw_word_t *offp,
void *arg)
{
return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp);
return _Uelf64_get_proc_name (as, getpid (), ip, buf, buf_len, offp, arg);
}

static int
Expand Down
2 changes: 1 addition & 1 deletion src/nto/unw_nto_find_proc_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int unw_nto_find_proc_info (unw_addr_space_t as,
&segbase,
&mapoff,
path,
sizeof (path));
sizeof (path),arg);

if (ret >= 0)
{
Expand Down
4 changes: 2 additions & 2 deletions src/os-freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ get_pid_by_tid(int tid)
}

int
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff, char *path, size_t pathlen)
tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff, char *path, size_t pathlen, void *arg)
{
int mib[4], error, ret;
size_t len, len1;
Expand Down
4 changes: 2 additions & 2 deletions src/os-hpux.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "elf64.h"

HIDDEN int
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
tdep_get_elf_image (unw_addr_space_t as, struct elf_image *ei, pid_t pid, unw_word_t ip,
unsigned long *segbase, unsigned long *mapoff,
char *path, size_t pathlen)
char *path, size_t pathlen, void *arg)
{
struct load_module_desc lmd;
const char *path2;
Expand Down