1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-12-23 03:53:43 +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:
Arun Sharma 2010-05-15 12:14:09 -07:00
parent b115ab645a
commit 1787a2fd28
13 changed files with 44 additions and 18 deletions

View file

@ -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);
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,
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,
unw_word_t *valp, int write);
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,

View file

@ -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);
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,
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,
unw_word_t *valp, int write);
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,

View file

@ -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,
uint8_t *nat_bitnr);
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,
unw_word_t *valp, int write);
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,

View file

@ -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);
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,
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,
unw_word_t *valp, int write);
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,

View file

@ -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);
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,
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,
unw_word_t * valp, int write);
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,

View file

@ -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);
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,
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,
unw_word_t * valp, int write);
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,

View file

@ -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);
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,
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,
unw_word_t *valp, int write);
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,

View file

@ -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);
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,
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,
unw_word_t *valp, int write);
extern int tdep_access_fpreg (struct cursor *c, unw_regnum_t reg,

View file

@ -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. */
#include <stdio.h>
#include <sys/param.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;
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)
return ret;

View file

@ -52,7 +52,7 @@ free_mem(void *ptr, size_t sz)
PROTECTED 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)
{
int mib[4], error, ret;
size_t len, len1;
@ -87,6 +87,10 @@ tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
break;
*segbase = kv->kve_start;
*mapoff = kv->kve_offset;
if (path)
{
strncpy(path, kb->kve_path, pathlen);
}
ret = elf_map_image(ei, kv->kve_path);
break;
}

View file

@ -26,6 +26,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#ifndef UNW_REMOTE_ONLY
#include <dlfcn.h>
#include <string.h>
#include <unistd.h>
#include "libunwind_i.h"
@ -34,10 +35,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
HIDDEN 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);
{
struct load_module_desc lmd;
const char *path;
const char *path2;
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;
*mapoff = 0; /* XXX fix me? */
path = dlgetname (&lmd, sizeof (lmd), NULL, 0, 0);
if (!path)
path2 = dlgetname (&lmd, sizeof (lmd), NULL, 0, 0);
if (!path2)
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);
return elf_map_image (ei, path);

View file

@ -33,7 +33,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
PROTECTED 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)
{
struct map_iterator mi;
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);
return -1;
}
if (path)
{
strncpy(path, mi.path, pathlen);
}
rc = elf_map_image (ei, mi.path);
maps_close (&mi);
return rc;

View file

@ -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;
}
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;
/* Here, SEGBASE is the starting-address of the (mmap'ped) segment