sysprof r408 - trunk
- From: ssp svn gnome org
- To: svn-commits-list gnome org
- Subject: sysprof r408 - trunk
- Date: Sat, 29 Mar 2008 23:02:01 +0000 (GMT)
Author: ssp
Date: Sat Mar 29 23:02:01 2008
New Revision: 408
URL: http://svn.gnome.org/viewvc/sysprof?rev=408&view=rev
Log:
Split decode_entry
Modified:
trunk/unwind.c
Modified: trunk/unwind.c
==============================================================================
--- trunk/unwind.c (original)
+++ trunk/unwind.c Sat Mar 29 23:02:01 2008
@@ -225,51 +225,84 @@
}
}
-
static void
-decode_entry (const guchar *data)
+decode_cie (const guchar **data, const guchar *end)
{
- guint64 len, aug_len;
- const guchar *end;
gboolean has_augmentation;
+ guint64 aug_len;
+
+ g_print ("version: %d\n", *(*data)++);
+
+ g_print ("augmentation: %s\n", *data);
+
+ has_augmentation = strchr (*data, 'z');
+
+ *data += strlen (*data) + 1;
- len = get_length (&data);
+ g_print ("code alignment: %llu\n", decode_uleb128 (data));
- end = data + len;
-
- g_print ("length: %llu\n", len);
+ g_print ("data alignment: %lld\n", decode_sleb128 (data));
- /* CIE_id is 0 for eh frames, and 0xffffffff/0xffffffffffffffff for .debug_frame */
-
- g_print ("id: %d\n", *(guint32 *)data);
+ g_print ("return register: %llu\n", decode_uleb128 (data));
+
+ if (has_augmentation)
+ {
+ g_print ("augmentation length: %llu\n",
+ (aug_len = decode_uleb128 (data)));
- data += 4;
+ *data += aug_len;
+ }
+
+ while (*data < end)
+ g_print (" %s\n", decode_instruction (data));
+}
- g_print ("version: %d\n", *data);
+static gboolean
+decode_fde (const guchar **data, const guchar *end)
+{
+
+
+ return FALSE;
+}
- data += 1;
+static gboolean
+decode_entry (const guchar **data, gboolean eh_frame)
+{
+ guint64 len;
+ const guchar *end;
+ gboolean is_cie;
+ guint64 id;
- g_print ("augmentation: %s\n", data);
+ len = get_length (data);
- has_augmentation = strchr (data, 'z');
+ if (len == 0)
+ return FALSE;
- data += strlen (data) + 1;
+ end = *data + len;
+
+ g_print ("length: %llu\n", len);
- g_print ("code alignment: %llu\n", decode_uleb128 (&data));
+ /* CIE_id is 0 for eh frames, and 0xffffffff/0xffffffffffffffff for .debug_frame */
+
+ id = *(guint32 *)*data;
- g_print ("data alignment: %lld\n", decode_sleb128 (&data));
+ g_print ("id: %lld\n", id);
- g_print ("return register: %llu\n", decode_uleb128 (&data));
+ is_cie = (eh_frame && id == 0) || (!eh_frame && id == 0xffffffff);
- if (has_augmentation)
- {
- g_print ("augmentation length: %llu\n", (aug_len = decode_uleb128 (&data)));
+ if (is_cie)
+ g_print ("is cie\n");
+ else
+ g_print ("is not cie\n");
+
+ *data += 4;
- data += aug_len;
- }
+ if (is_cie)
+ decode_cie (data, end);
+ else
+ decode_fde (data, end);
- while (data < end)
- g_print (" %s\n", decode_instruction (&data));
+ return TRUE;
}
/* The correct API is probably something like
@@ -286,14 +319,17 @@
unwind (ElfParser *elf)
{
const guchar *data;
+ gboolean eh_f;
if ((data = elf_parser_get_debug_frame (elf)))
{
g_print ("Using .debug_frame\n");
+ eh_f = FALSE;
}
else if ((data = elf_parser_get_eh_frame (elf)))
{
g_print ("Using .eh_frame\n");
+ eh_f = TRUE;
}
else
{
@@ -301,6 +337,7 @@
return;
}
- decode_entry (data);
+ while (decode_entry (&data, eh_f))
+ ;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]