From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2022 invoked by alias); 29 May 2003 13:46:20 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 1990 invoked from network); 29 May 2003 13:46:19 -0000 Received: from unknown (HELO kerberos.suse.cz) (195.47.106.10) by sources.redhat.com with SMTP; 29 May 2003 13:46:19 -0000 Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by kerberos.suse.cz (SuSE SMTP server) with ESMTP id 6A19359D6B0; Thu, 29 May 2003 15:46:18 +0200 (CEST) Received: from suse.cz (naga.suse.cz [10.20.1.16]) by chimera.suse.cz (Postfix) with ESMTP id 5283E4DA2; Thu, 29 May 2003 15:46:18 +0200 (CEST) Message-ID: <3ED60F2A.9060108@suse.cz> Date: Thu, 29 May 2003 13:46:00 -0000 From: Michal Ludvig Organization: SuSE CR, s.r.o. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20030507 X-Accept-Language: cs, cz, en MIME-Version: 1.0 To: Mark Kettenis Cc: GDB Patches Subject: [RFA/i386newframe] info cfi command Content-Type: multipart/mixed; boundary="------------090100010308010309030207" X-SW-Source: 2003-05/txt/msg00535.txt.bz2 This is a multi-part message in MIME format. --------------090100010308010309030207 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 371 Hi, this patch adds 'info cfi' command which is to be used for examining debug info. For now it only prints the instructions in a hex-form, but I'll make a resolver to nice strings later. It doesn't change anything except that it adds a new command. Can I commit it? Michal Ludvig -- * SuSE CR, s.r.o * mludvig@suse.cz * (+420) 296.545.373 * http://www.suse.cz --------------090100010308010309030207 Content-Type: text/plain; name="nf-cmd-infocfi-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="nf-cmd-infocfi-1.diff" Content-length: 3030 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); } --------------090100010308010309030207--