mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2025-01-10 19:23:41 +01:00
Add path and pathlen arguments to tdep_get_elf_image()
Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
This commit is contained in:
parent
b115ab645a
commit
1787a2fd28
13 changed files with 44 additions and 18 deletions
|
@ -248,7 +248,8 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
|
||||||
int need_unwind_info, void *arg);
|
int need_unwind_info, void *arg);
|
||||||
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
|
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 (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff);
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
||||||
unw_word_t *valp, int write);
|
unw_word_t *valp, int write);
|
||||||
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
||||||
|
|
|
@ -255,7 +255,8 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
|
||||||
int need_unwind_info, void *arg);
|
int need_unwind_info, void *arg);
|
||||||
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
|
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 (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff);
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
||||||
unw_word_t *valp, int write);
|
unw_word_t *valp, int write);
|
||||||
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
||||||
|
|
|
@ -247,7 +247,8 @@ extern void tdep_put_unwind_info (unw_addr_space_t as,
|
||||||
extern void *tdep_uc_addr (ucontext_t *uc, unw_regnum_t regnum,
|
extern void *tdep_uc_addr (ucontext_t *uc, unw_regnum_t regnum,
|
||||||
uint8_t *nat_bitnr);
|
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 (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff);
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
||||||
unw_word_t *valp, int write);
|
unw_word_t *valp, int write);
|
||||||
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
||||||
|
|
|
@ -309,7 +309,8 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
|
||||||
int need_unwind_info, void *arg);
|
int need_unwind_info, void *arg);
|
||||||
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
|
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 (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff);
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
||||||
unw_word_t *valp, int write);
|
unw_word_t *valp, int write);
|
||||||
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
||||||
|
|
|
@ -292,7 +292,8 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
|
||||||
int need_unwind_info, void *arg);
|
int need_unwind_info, void *arg);
|
||||||
extern void *tdep_uc_addr (ucontext_t * uc, int reg);
|
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 (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff);
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
||||||
unw_word_t * valp, int write);
|
unw_word_t * valp, int write);
|
||||||
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
||||||
|
|
|
@ -292,7 +292,8 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
|
||||||
int need_unwind_info, void *arg);
|
int need_unwind_info, void *arg);
|
||||||
extern void *tdep_uc_addr (ucontext_t * uc, int reg);
|
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 (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff);
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
||||||
unw_word_t * valp, int write);
|
unw_word_t * valp, int write);
|
||||||
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
||||||
|
|
|
@ -271,7 +271,8 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
|
||||||
int need_unwind_info, void *arg);
|
int need_unwind_info, void *arg);
|
||||||
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
|
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 (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff);
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
||||||
unw_word_t *valp, int write);
|
unw_word_t *valp, int write);
|
||||||
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
||||||
|
|
|
@ -200,7 +200,8 @@ extern int tdep_search_unwind_table (unw_addr_space_t as, unw_word_t ip,
|
||||||
int need_unwind_info, void *arg);
|
int need_unwind_info, void *arg);
|
||||||
extern void *tdep_uc_addr (ucontext_t *uc, int reg);
|
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 (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff);
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_reg (struct cursor *c, unw_regnum_t reg,
|
||||||
unw_word_t *valp, int write);
|
unw_word_t *valp, int write);
|
||||||
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,
|
||||||
|
|
|
@ -25,6 +25,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include "libunwind_i.h"
|
#include "libunwind_i.h"
|
||||||
|
|
||||||
|
@ -147,7 +148,7 @@ elf_w (get_proc_name) (unw_addr_space_t as, pid_t pid, unw_word_t ip,
|
||||||
Elf_W (Phdr) *phdr;
|
Elf_W (Phdr) *phdr;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff);
|
ret = tdep_get_elf_image (&ei, pid, ip, &segbase, &mapoff, NULL, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ free_mem(void *ptr, size_t sz)
|
||||||
|
|
||||||
PROTECTED int
|
PROTECTED int
|
||||||
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff)
|
unsigned long *segbase, unsigned long *mapoff, char *path, size_t pathlen)
|
||||||
{
|
{
|
||||||
int mib[4], error, ret;
|
int mib[4], error, ret;
|
||||||
size_t len, len1;
|
size_t len, len1;
|
||||||
|
@ -87,6 +87,10 @@ tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
break;
|
break;
|
||||||
*segbase = kv->kve_start;
|
*segbase = kv->kve_start;
|
||||||
*mapoff = kv->kve_offset;
|
*mapoff = kv->kve_offset;
|
||||||
|
if (path)
|
||||||
|
{
|
||||||
|
strncpy(path, kb->kve_path, pathlen);
|
||||||
|
}
|
||||||
ret = elf_map_image(ei, kv->kve_path);
|
ret = elf_map_image(ei, kv->kve_path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
#ifndef UNW_REMOTE_ONLY
|
#ifndef UNW_REMOTE_ONLY
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "libunwind_i.h"
|
#include "libunwind_i.h"
|
||||||
|
@ -34,10 +35,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
HIDDEN int
|
HIDDEN int
|
||||||
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff)
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen);
|
||||||
{
|
{
|
||||||
struct load_module_desc lmd;
|
struct load_module_desc lmd;
|
||||||
const char *path;
|
const char *path2;
|
||||||
|
|
||||||
if (pid != getpid ())
|
if (pid != getpid ())
|
||||||
{
|
{
|
||||||
|
@ -51,10 +53,16 @@ tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
*segbase = lmd.text_base;
|
*segbase = lmd.text_base;
|
||||||
*mapoff = 0; /* XXX fix me? */
|
*mapoff = 0; /* XXX fix me? */
|
||||||
|
|
||||||
path = dlgetname (&lmd, sizeof (lmd), NULL, 0, 0);
|
path2 = dlgetname (&lmd, sizeof (lmd), NULL, 0, 0);
|
||||||
if (!path)
|
if (!path2)
|
||||||
return -UNW_ENOINFO;
|
return -UNW_ENOINFO;
|
||||||
|
if (path)
|
||||||
|
{
|
||||||
|
strncpy(path, path2, pathlen);
|
||||||
|
path[pathlen - 1] = '\0';
|
||||||
|
if (strcmp(path, path2) != 0)
|
||||||
|
Debug(1, "buffer size (%d) not big enough to hold path\n", pathlen);
|
||||||
|
}
|
||||||
Debug(1, "segbase=%lx, mapoff=%lx, path=%s\n", *segbase, *mapoff, path);
|
Debug(1, "segbase=%lx, mapoff=%lx, path=%s\n", *segbase, *mapoff, path);
|
||||||
|
|
||||||
return elf_map_image (ei, path);
|
return elf_map_image (ei, path);
|
||||||
|
|
|
@ -33,7 +33,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
|
|
||||||
PROTECTED int
|
PROTECTED int
|
||||||
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
unsigned long *segbase, unsigned long *mapoff)
|
unsigned long *segbase, unsigned long *mapoff,
|
||||||
|
char *path, size_t pathlen)
|
||||||
{
|
{
|
||||||
struct map_iterator mi;
|
struct map_iterator mi;
|
||||||
int found = 0, rc;
|
int found = 0, rc;
|
||||||
|
@ -54,7 +55,10 @@ tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
|
||||||
maps_close (&mi);
|
maps_close (&mi);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (path)
|
||||||
|
{
|
||||||
|
strncpy(path, mi.path, pathlen);
|
||||||
|
}
|
||||||
rc = elf_map_image (ei, mi.path);
|
rc = elf_map_image (ei, mi.path);
|
||||||
maps_close (&mi);
|
maps_close (&mi);
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -342,7 +342,8 @@ get_unwind_info (struct UPT_info *ui, unw_addr_space_t as, unw_word_t ip)
|
||||||
ui->di_cache.start_ip = ui->di_cache.end_ip = 0;
|
ui->di_cache.start_ip = ui->di_cache.end_ip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tdep_get_elf_image (&ui->ei, ui->pid, ip, &segbase, &mapoff) < 0)
|
if (tdep_get_elf_image (&ui->ei, ui->pid, ip, &segbase, &mapoff, path,
|
||||||
|
sizeof(path)) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Here, SEGBASE is the starting-address of the (mmap'ped) segment
|
/* Here, SEGBASE is the starting-address of the (mmap'ped) segment
|
||||||
|
|
Loading…
Reference in a new issue