Browse Source

Clean up warnings

master
aolo2 3 years ago
parent
commit
eb132ccb4c
  1. 4
      command.c
  2. 14
      eh_frame.c
  3. 7
      util.c

4
command.c

@ -150,12 +150,12 @@ command_print(struct mi_process proc, char *name, int name_length)
u64 cfa = get_cfa_at_pc(proc, pc); u64 cfa = get_cfa_at_pc(proc, pc);
struct mi_variable *variable = get_variable(proc, name, name_length, pc); struct mi_variable *variable = get_variable(proc, name, name_length, pc);
if (variable) { if (cfa && variable) {
u64 address = cfa + variable->location; u64 address = cfa + variable->location;
long value = ptrace(PTRACE_PEEKDATA, proc.pid, address, NULL); long value = ptrace(PTRACE_PEEKDATA, proc.pid, address, NULL);
int val4 = value & 0x00000000FFFFFFFF; int val4 = value & 0x00000000FFFFFFFF;
printf("%.*s = %d\n", name_length, name, val4); printf("%.*s = %d\n", name_length, name, val4);
} else { } else {
printf("variable %.*s not found\n", name_length, name); printf("Variable %.*s not found\n", name_length, name);
} }
} }

14
eh_frame.c

@ -1,6 +1,6 @@
static u64 static u64
iterate_call_frame_instructions(struct dwarf_cie *cie, u8 *data, u64 to_read, iterate_call_frame_instructions(struct dwarf_cie *cie, u8 *data, u64 to_read,
struct mi_registers *regs, struct dwarf_regset *regset, u64 location) struct dwarf_regset *regset, u64 location)
{ {
u64 read = 0; u64 read = 0;
@ -274,7 +274,7 @@ read_one_cie(struct dwarf_cie *header, u64 length, u8 *data, u8 *original_data)
header->instructions = data; header->instructions = data;
header->instructions_length = header->length - (data - original_data - 4); header->instructions_length = header->length - (data - original_data - 4);
data += iterate_call_frame_instructions(header, data, header->instructions_length, 0, 0, 0); data += iterate_call_frame_instructions(header, data, header->instructions_length, 0, 0);
if (has_R) { if (has_R) {
// NOTE(aolo2): this shit is undocumented. Best sources I could find: // NOTE(aolo2): this shit is undocumented. Best sources I could find:
@ -441,7 +441,7 @@ read_one_fde(struct mi_process proc, struct dwarf_cie *cie, u64 length, u8 *data
header->instructions = data; header->instructions = data;
header->instructions_length = header->length - (data - original_data - 4); header->instructions_length = header->length - (data - original_data - 4);
data += iterate_call_frame_instructions(cie, data, header->instructions_length, 0, 0, 0); data += iterate_call_frame_instructions(cie, data, header->instructions_length, 0, 0);
return(data - original_data); return(data - original_data);
} }
@ -515,7 +515,7 @@ eh_frame_find_fde(struct mi_process proc, u64 pc)
} }
static struct dwarf_regset static struct dwarf_regset
eh_frame_init_registers(struct mi_process proc, struct mi_registers regs, struct dwarf_cie cie) eh_frame_init_registers(struct mi_registers regs, struct dwarf_cie cie)
{ {
struct dwarf_regset regset = { 0 }; struct dwarf_regset regset = { 0 };
@ -536,15 +536,15 @@ eh_frame_init_registers(struct mi_process proc, struct mi_registers regs, struct
regset.system[14] = regs._sys.r14; regset.system[14] = regs._sys.r14;
regset.system[15] = regs._sys.r15; regset.system[15] = regs._sys.r15;
iterate_call_frame_instructions(&cie, cie.instructions, cie.instructions_length, &regs, &regset, 0); iterate_call_frame_instructions(&cie, cie.instructions, cie.instructions_length, &regset, 0);
return(regset); return(regset);
} }
static struct dwarf_regset static struct dwarf_regset
eh_frame_find_pc(struct mi_process proc, struct dwarf_fde fde, struct mi_registers regs, struct dwarf_regset regset, u64 pc) eh_frame_find_pc(struct dwarf_fde fde, struct dwarf_regset regset, u64 pc)
{ {
regset.loc = fde.low_pc; regset.loc = fde.low_pc;
iterate_call_frame_instructions(&fde.cie, fde.instructions, fde.instructions_length, &regs, &regset, pc); iterate_call_frame_instructions(&fde.cie, fde.instructions, fde.instructions_length, &regset, pc);
return(regset); return(regset);
} }

7
util.c

@ -338,13 +338,14 @@ get_cfa_at_pc(struct mi_process proc, u64 pc)
{ {
struct dwarf_fde fde = eh_frame_find_fde(proc, pc); struct dwarf_fde fde = eh_frame_find_fde(proc, pc);
if (!fde.length) { if (!fde.length) {
DIE("could not find FDE for pc!\n"); printf("Could not find FDE for pc %#lx\n", pc);
return(0);
} }
struct mi_registers regs = get_process_registers(proc); struct mi_registers regs = get_process_registers(proc);
struct dwarf_regset regset = eh_frame_init_registers(proc, regs, fde.cie); struct dwarf_regset regset = eh_frame_init_registers(regs, fde.cie);
regset = eh_frame_find_pc(proc, fde, regs, regset, pc); regset = eh_frame_find_pc(fde, regset, pc);
return(regset.cfa); return(regset.cfa);
} }
Loading…
Cancel
Save