2003-05-29 Michal Ludvig * dwarf-frame.c (cfi_info, _initialize_dwarf_frame): New functions. Index: dwarf-frame.c =================================================================== RCS file: /cvs/src/src/gdb/Attic/dwarf-frame.c,v retrieving revision 1.1.2.6 diff -u -p -r1.1.2.6 dwarf-frame.c --- dwarf-frame.c 23 May 2003 20:18:32 -0000 1.1.2.6 +++ dwarf-frame.c 29 May 2003 13:28:08 -0000 @@ -32,6 +32,8 @@ #include "symtab.h" #include "objfiles.h" #include "regcache.h" +#include "gdbcmd.h" +#include "value.h" #include "gdb_assert.h" #include @@ -1232,4 +1234,83 @@ dwarf2_build_frame_info (struct objfile while (frame_ptr < unit.dwarf_frame_buffer + unit.dwarf_frame_size) frame_ptr = decode_frame_entry (&unit, frame_ptr, 0); } +} + +/* Interactive interface. */ + +static void +cfi_info (char *arg, int from_tty) +{ + CORE_ADDR addr, low, high; + unsigned long data_length; + struct dwarf2_fde *fde; + char *name; + int i; + + if (! arg) + error_no_arg ("address"); + + addr = parse_and_eval_address (arg); + printf_filtered ("Searching CFI for address %p...\n", (void*)addr); + + if (find_pc_partial_function (addr, &name, &low, &high)) + printf_filtered ("\tBelongs to function '%s' (%p..%p).\n", + name, (void*)low, (void*)high); + + fde = dwarf2_frame_find_fde (&addr); + if (! fde) + { + printf_filtered ("\tCFI entry not found.\n"); + return; + } + + /* Print out CIE. */ + data_length = fde->cie->end - fde->cie->initial_instructions; + printf_filtered ("CIE:\n"); + printf_filtered ("\toffset = %llx\n" + "\tcode_align = %llu, data_align = %lld, ra_column = 0x%llx\n" + "\tdata_length = %lu, data: \n\t", + fde->cie->cie_pointer, + fde->cie->code_alignment_factor, + fde->cie->data_alignment_factor, + fde->cie->return_address_register, + data_length); + + for (i = 0; i < data_length; i++) + { + printf_filtered ("0x%02x ", fde->cie->initial_instructions[i] & 0xff); + if ((i + 1) % 8 == 0) + printf_filtered ("\n\t"); + else if ((i + 1) % 4 == 0) + printf_filtered (" "); + } + if (i % 8) + printf_filtered ("\n"); + + /* Print out FDE. */ + data_length = fde->end - fde->instructions; + printf_filtered ("FDE:\n"); + printf_filtered ("\tlocation = 0x%llx..0x%llx (size = %lld)\n" + "\tdata_length = %lu, data: \n\t", + fde->initial_location, + (fde->initial_location + fde->address_range), + fde->address_range, data_length); + for (i = 0; i < data_length; i++) + { + printf_filtered ("0x%02x ", fde->instructions[i] & 0xff); + if ((i + 1) % 8 == 0) + printf_filtered ("\n%s", i + 1 < data_length ? "\t" : ""); + else if ((i + 1) % 4 == 0) + printf_filtered (" "); + } + if (i % 8) + printf_filtered ("\n"); +} + +void +_initialize_dwarf_frame (void) +{ + add_info ("cfi", cfi_info, "Find and print CFI for a given address."); + add_info_alias ("fde", "cfi", 1); + add_info_alias ("cie", "cfi", 1); }