PROTECTED 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) { struct map_iterator mi; int found = 0, rc; unsigned long hi; if (maps_init (&mi, pid) < 0) return -1; while (maps_next (&mi, segbase, &hi, mapoff)) if (ip >= *segbase && ip < hi) { found = 1; break; } if (!found) { maps_close (&mi); return -1; } if (path) { strncpy(path, mi.path, pathlen); } rc = elf_map_image (ei, mi.path); maps_close (&mi); return rc; }
/* ANDROID support update. */ HIDDEN struct map_info * map_create_list (pid_t pid) { struct map_iterator mi; unsigned long start, end, offset, flags; struct map_info *map_list = NULL; struct map_info *cur_map; if (maps_init (&mi, pid) < 0) return NULL; while (maps_next (&mi, &start, &end, &offset, &flags)) { cur_map = map_alloc_info (); if (cur_map == MAP_FAILED) break; cur_map->next = map_list; cur_map->start = start; cur_map->end = end; cur_map->offset = offset; cur_map->flags = flags; cur_map->path = strdup (mi.path); mutex_init (&cur_map->ei_lock); cur_map->ei.size = 0; cur_map->ei.image = NULL; map_list = cur_map; } maps_close (&mi); return map_list; }
static inline int get_list_addr (unw_addr_space_t as, unw_word_t *dil_addr, void *arg, int *countp) { unsigned long lo, hi, off; struct UPT_info *ui = arg; struct map_iterator mi; char path[PATH_MAX]; unw_dyn_info_t *di; unw_word_t res; int count = 0; maps_init (&mi, ui->pid); while (maps_next (&mi, &lo, &hi, &off)) { if (off) continue; if (ui->ei.image) { munmap (ui->ei.image, ui->ei.size); ui->ei.image = NULL; ui->ei.size = 0; /* invalidate the cache: */ ui->di_cache.start_ip = ui->di_cache.end_ip = 0; } if (elf_map_image (&ui->ei, path) < 0) /* ignore unmappable stuff like "/SYSV00001b58 (deleted)" */ continue; Debug (16, "checking object %s\n", path); di = _UPTi_find_unwind_table (ui, as, path, lo, off); if (di) { res = _Uia64_find_dyn_list (as, di, arg); if (res && count++ == 0) { Debug (12, "dyn_info_list_addr = 0x%lx\n", (long) res); *dil_addr = res; } } } maps_close (&mi); *countp = count; return 0; }
int main(int argc, char **argv) { char *cp, *init_fcn_name = NULL; PF init_fcn = NULL; int o, i, nfiles; int nobackups = 0; struct buffer *bp = NULL; #ifdef MRUBY mrb_mg_init(); int noinitfile = 0; #endif /* MRUBY */ while ((o = getopt(argc, argv, "nf:q")) != -1) switch (o) { case 'n': nobackups = 1; break; case 'f': if (init_fcn_name != NULL) errx(1, "cannot specify more than one " "initial function"); init_fcn_name = optarg; break; case 'q': noinitfile = 1; break; default: usage(); } argc -= optind; argv += optind; maps_init(); /* Keymaps and modes. */ funmap_init(); /* Functions. */ /* * This is where we initialize standalone extensions that should * be loaded dynamically sometime in the future. */ { extern void grep_init(void); extern void theo_init(void); extern void cmode_init(void); extern void dired_init(void); dired_init(); grep_init(); theo_init(); cmode_init(); #ifdef UTF8 utf8_init(); #endif /* UTF8 */ } if (init_fcn_name && (init_fcn = name_function(init_fcn_name)) == NULL) errx(1, "Unknown function `%s'", init_fcn_name); vtinit(); /* Virtual terminal. */ dirinit(); /* Get current directory. */ edinit(bp); /* Buffers, windows. */ ttykeymapinit(); /* Symbols, bindings. */ /* * doing update() before reading files causes the error messages from * the file I/O show up on the screen. (and also an extra display of * the mode line if there are files specified on the command line.) */ update(); /* user startup file */ #ifdef MRUBY if (noinitfile == 0 && (cp = startupfile(NULL)) != NULL) mrb_mg_load(cp); #else if ((cp = startupfile(NULL)) != NULL) (void)load(cp); #endif /* MRUBY */ /* * Now ensure any default buffer modes from the startup file are * given to any files opened when parsing the startup file. * Note *scratch* will also be updated. */ for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { bp->b_flag = defb_flag; for (i = 0; i <= defb_nmodes; i++) { bp->b_modes[i] = defb_modes[i]; } } /* Force FFOTHARG=1 so that this mode is enabled, not simply toggled */ if (init_fcn) init_fcn(FFOTHARG, 1); if (nobackups) makebkfile(FFARG, 0); for (nfiles = 0, i = 0; i < argc; i++) { if (argv[i][0] == '+' && strlen(argv[i]) >= 2) { long long lval; const char *errstr; lval = strtonum(&argv[i][1], INT_MIN, INT_MAX, &errstr); if (argv[i][1] == '\0' || errstr != NULL) goto notnum; startrow = lval; } else { notnum: cp = adjustname(argv[i], FALSE); if (cp != NULL) { if (nfiles == 1) splitwind(0, 1); if ((curbp = findbuffer(cp)) == NULL) { vttidy(); errx(1, "Can't find current buffer!"); } (void)showbuffer(curbp, curwp, 0); if (readin(cp) != TRUE) killbuffer(curbp); else { /* Ensure enabled, not just toggled */ if (init_fcn_name) init_fcn(FFOTHARG, 1); nfiles++; } } } } if (nfiles > 2) listbuffers(0, 1); /* fake last flags */ thisflag = 0; for (;;) { if (epresf == KCLEAR) eerase(); if (epresf == TRUE) epresf = KCLEAR; if (winch_flag) { do_redraw(0, 0, TRUE); winch_flag = 0; } update(); lastflag = thisflag; thisflag = 0; switch (doin()) { case TRUE: break; case ABORT: ewprintf("Quit"); /* FALLTHRU */ case FALSE: default: ttbeep(); macrodef = FALSE; } } }
int main(int argc, char **argv) { char *cp, *init_fcn_name = NULL; PF init_fcn = NULL; int o, i, nfiles; struct buffer *bp = NULL; while ((o = getopt(argc, argv, "f:")) != -1) switch (o) { case 'f': if (init_fcn_name != NULL) errx(1, "cannot specify more than one " "initial function"); init_fcn_name = optarg; break; default: usage(); } argc -= optind; argv += optind; setlocale(LC_CTYPE, ""); maps_init(); /* Keymaps and modes. */ funmap_init(); /* Functions. */ if (init_fcn_name && (init_fcn = name_function(init_fcn_name)) == NULL) errx(1, "Unknown function `%s'", init_fcn_name); vtinit(); /* Virtual terminal. */ dirinit(); /* Get current directory. */ edinit(bp); /* Buffers, windows. */ bellinit(); /* Audible and visible bell. */ /* * doing update() before reading files causes the error messages from * the file I/O show up on the screen. (and also an extra display of * the mode line if there are files specified on the command line.) */ update(CMODE); /* Force FFOTHARG=1 so that this mode is enabled, not simply toggled */ if (init_fcn) init_fcn(FFOTHARG, 1); for (nfiles = 0, i = 0; i < argc; i++) { if (argv[i][0] == '+' && strlen(argv[i]) >= 2) { long lval; char *end; lval = strtol(&argv[i][1], &end, 0); if (argv[i][1] == '\0' || *end != '\0') goto notnum; startrow = lval; } else { notnum: cp = adjustname(argv[i], FALSE); if (cp != NULL) { if (nfiles == 1) splitwind(0, 1); if ((curbp = findbuffer(cp)) == NULL) { vttidy(); errx(1, "Can't find current buffer!"); } (void)showbuffer(curbp, curwp, 0); if (readin(cp) != TRUE) killbuffer(curbp); else { /* Ensure enabled, not just toggled */ if (init_fcn_name) init_fcn(FFOTHARG, 1); nfiles++; } } } } if (nfiles > 2) listbuffers(0, 1); /* fake last flags */ thisflag = 0; for (;;) { if (epresf == KCLEAR) eerase(); if (epresf == TRUE) epresf = KCLEAR; if (winch_flag) { do_redraw(0, 0, TRUE); winch_flag = 0; } update(CMODE); lastflag = thisflag; thisflag = 0; switch (doin()) { case TRUE: break; case ABORT: ewprintf("Quit"); /* FALLTHRU */ case FALSE: default: macrodef = FALSE; } } }