Lines Matching +full:resume +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0
9 * Copyright (C) 2002-2007 Hewlett-Packard Co
10 * Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
31 #include <libunwind-ptrace.h>
65 /* Pointer-encoding formats: */
67 #define DW_EH_PE_ptr 0x00 /* pointer-sized unsigned value */
68 #define DW_EH_PE_udata4 0x03 /* unsigned 32-bit value */
69 #define DW_EH_PE_udata8 0x04 /* unsigned 64-bit value */
70 #define DW_EH_PE_sdata4 0x0b /* signed 32-bit value */
71 #define DW_EH_PE_sdata8 0x0c /* signed 64-bit value */
73 /* Pointer-encoding application: */
82 #define DW_EH_PE_funcrel 0x40 /* start-of-procedure-relative */
106 return -EINVAL; \
136 return -EINVAL; in __dw_read_encoded_value()
156 return -EINVAL; in __dw_read_encoded_value()
167 return -EINVAL; \
172 static int elf_section_address_and_offset(int fd, const char *name, u64 *address, u64 *offset) in elf_section_address_and_offset() argument
177 int ret = -1; in elf_section_address_and_offset()
181 return -1; in elf_section_address_and_offset()
190 *offset = shdr.sh_offset; in elf_section_address_and_offset()
200 u64 address, offset = 0; in elf_section_offset() local
202 if (elf_section_address_and_offset(fd, name, &address, &offset)) in elf_section_offset()
205 return offset; in elf_section_offset()
222 retval = phdr.p_vaddr & -getpagesize(); in elf_base_address()
265 * The rest of the header is variable-length and consists of the
285 u64 offset, u64 *table_data_offset, u64 *fde_count) in unwind_spec_ehframe() argument
292 r = dso__data_read_offset(dso, machine, offset, in unwind_spec_ehframe()
295 return -EINVAL; in unwind_spec_ehframe()
301 *table_data_offset = enc - (u8 *) &hdr; in unwind_spec_ehframe()
315 if (map__dso(map) == args->dso && map__start(map) - map__pgoff(map) < args->base_addr) in read_unwind_spec_eh_frame_maps_cb()
316 args->base_addr = map__start(map) - map__pgoff(map); in read_unwind_spec_eh_frame_maps_cb()
332 if (dso__data(dso)->eh_frame_hdr_offset == 0) { in read_unwind_spec_eh_frame()
333 if (!dso__data_get_fd(dso, ui->machine, &fd)) in read_unwind_spec_eh_frame()
334 return -EINVAL; in read_unwind_spec_eh_frame()
338 &dso__data(dso)->eh_frame_hdr_addr, in read_unwind_spec_eh_frame()
339 &dso__data(dso)->eh_frame_hdr_offset); in read_unwind_spec_eh_frame()
340 dso__data(dso)->elf_base_addr = elf_base_address(fd); in read_unwind_spec_eh_frame()
342 if (ret || dso__data(dso)->eh_frame_hdr_offset == 0) in read_unwind_spec_eh_frame()
343 return -EINVAL; in read_unwind_spec_eh_frame()
346 maps__for_each_map(thread__maps(ui->thread), read_unwind_spec_eh_frame_maps_cb, &args); in read_unwind_spec_eh_frame()
348 args.base_addr -= dso__data(dso)->elf_base_addr; in read_unwind_spec_eh_frame()
350 *segbase = args.base_addr + dso__data(dso)->eh_frame_hdr_addr; in read_unwind_spec_eh_frame()
351 ret = unwind_spec_ehframe(dso, ui->machine, dso__data(dso)->eh_frame_hdr_offset, in read_unwind_spec_eh_frame()
355 /* binary_search_table offset plus .eh_frame_hdr address */ in read_unwind_spec_eh_frame()
362 struct machine *machine, u64 *offset) in read_unwind_spec_debug_frame() argument
365 u64 ofs = dso__data(dso)->debug_frame_offset; in read_unwind_spec_debug_frame()
368 * - dso in read_unwind_spec_debug_frame()
369 * - debug pointed by symsrc_filename in read_unwind_spec_debug_frame()
370 * - gnu_debuglink, which doesn't necessary in read_unwind_spec_debug_frame()
393 return -ENOMEM; in read_unwind_spec_debug_frame()
398 machine->root_dir, debuglink, PATH_MAX); in read_unwind_spec_debug_frame()
422 dso__data(dso)->debug_frame_offset = ofs; in read_unwind_spec_debug_frame()
425 *offset = ofs; in read_unwind_spec_debug_frame()
426 if (*offset) in read_unwind_spec_debug_frame()
429 return -EINVAL; in read_unwind_spec_debug_frame()
439 thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al); in find_map()
454 int ret = -EINVAL; in find_proc_info()
458 return -EINVAL; in find_proc_info()
463 return -EINVAL; in find_proc_info()
485 !read_unwind_spec_debug_frame(dso, ui->machine, &segbase)) { in find_proc_info()
491 if (dso__data_get_fd(dso, ui->machine, &fd)) { in find_proc_info()
516 return -UNW_EINVAL; in access_fpreg()
523 return -UNW_ENOINFO; in get_dyn_info_list_addr()
526 static int resume(unw_addr_space_t __maybe_unused as, in resume() function
530 pr_err("unwind: resume unsupported\n"); in resume()
531 return -UNW_EINVAL; in resume()
541 return -UNW_EINVAL; in get_proc_name()
554 return -1; in access_dso_mem()
561 return -1; in access_dso_mem()
564 size = dso__data_read_addr(dso, map, ui->machine, in access_dso_mem()
575 const char *arch = perf_env__arch(ui->machine->env); in access_mem()
576 struct stack_dump *stack = &ui->sample->user_stack; in access_mem()
578 int offset; in access_mem() local
582 if (__write || !stack || !ui->sample->user_regs || !ui->sample->user_regs->regs) { in access_mem()
587 ret = perf_reg_value(&start, perf_sample__user_regs(ui->sample), in access_mem()
592 end = start + stack->size; in access_mem()
596 return -EINVAL; in access_mem()
602 " 0x%" PRIx64 "-0x%" PRIx64 "\n", in access_mem()
610 offset = addr - start; in access_mem()
611 *valp = *(unw_word_t *)&stack->data[offset]; in access_mem()
612 pr_debug("unwind: access_mem addr %p val %lx, offset %d\n", in access_mem()
613 (void *) (uintptr_t) addr, (unsigned long)*valp, offset); in access_mem()
631 if (!ui->sample->user_regs || !ui->sample->user_regs->regs) { in access_reg()
638 return -EINVAL; in access_reg()
640 ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample), id); in access_reg()
642 if (!ui->best_effort) in access_reg()
673 al.sym ? al.sym->name : "''", in entry()
706 .resume = resume,
717 return -ENOMEM; in _unwind__prepare_access()
737 const char *arch = perf_env__arch(ui->machine->env); in get_entries()
744 ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample), in get_entries()
755 if (max_stack - 1 > 0) { in get_entries()
756 WARN_ONCE(!ui->thread, "WARNING: ui->thread is NULL"); in get_entries()
757 addr_space = maps__addr_space(thread__maps(ui->thread)); in get_entries()
760 return -1; in get_entries()
763 if (ret && !ui->best_effort) in get_entries()
770 * Decrement the IP for any non-activation frames. in get_entries()
777 --ips[i]; in get_entries()
792 j = max_stack - i - 1; in get_entries()
793 ret = ips[j] ? entry(ips[j], ui->thread, cb, arg) : 0; in get_entries()
811 if (!data->user_regs || !data->user_regs->regs) in _unwind__get_entries()
812 return -EINVAL; in _unwind__get_entries()
815 return -EINVAL; in _unwind__get_entries()