Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA/i386newframe] info cfi command
@ 2003-05-29 13:46 Michal Ludvig
  2003-05-29 14:16 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Michal Ludvig @ 2003-05-29 13:46 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: GDB Patches

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

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

[-- Attachment #2: nf-cmd-infocfi-1.diff --]
[-- Type: text/plain, Size: 3030 bytes --]

2003-05-29  Michal Ludvig  <mludvig@suse.cz>

	* 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 <stddef.h>
@@ -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);
 }

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-06-03  0:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-29 13:46 [RFA/i386newframe] info cfi command Michal Ludvig
2003-05-29 14:16 ` Eli Zaretskii
2003-05-29 14:56   ` Michal Ludvig
2003-05-29 16:29 ` Mark Kettenis
2003-05-29 18:14   ` Andrew Cagney
2003-05-30 12:33   ` Michal Ludvig
2003-05-31 16:35     ` Mark Kettenis
2003-05-31 16:47       ` Andrew Cagney
2003-05-31 16:49       ` Michal Ludvig
2003-06-01 16:24     ` Eli Zaretskii
2003-06-03  0:39 ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox