aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/linux-low.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/gdbserver/linux-low.c')
-rw-r--r--gdb/gdbserver/linux-low.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 1682679..8bc73a4 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -103,6 +103,7 @@
#ifdef HAVE_LINUX_BTRACE
# include "nat/linux-btrace.h"
+# include "btrace-common.h"
#endif
#ifndef HAVE_ELF32_AUXV_T
@@ -5971,12 +5972,13 @@ static int
linux_low_read_btrace (struct btrace_target_info *tinfo, struct buffer *buffer,
int type)
{
- VEC (btrace_block_s) *btrace;
+ struct btrace_data btrace;
struct btrace_block *block;
enum btrace_error err;
int i;
- btrace = NULL;
+ btrace_data_init (&btrace);
+
err = linux_read_btrace (&btrace, tinfo, type);
if (err != BTRACE_ERR_NONE)
{
@@ -5985,20 +5987,37 @@ linux_low_read_btrace (struct btrace_target_info *tinfo, struct buffer *buffer,
else
buffer_grow_str0 (buffer, "E.Generic Error.");
+ btrace_data_fini (&btrace);
return -1;
}
- buffer_grow_str (buffer, "<!DOCTYPE btrace SYSTEM \"btrace.dtd\">\n");
- buffer_grow_str (buffer, "<btrace version=\"1.0\">\n");
+ switch (btrace.format)
+ {
+ case BTRACE_FORMAT_NONE:
+ buffer_grow_str0 (buffer, "E.No Trace.");
+ break;
+
+ case BTRACE_FORMAT_BTS:
+ buffer_grow_str (buffer, "<!DOCTYPE btrace SYSTEM \"btrace.dtd\">\n");
+ buffer_grow_str (buffer, "<btrace version=\"1.0\">\n");
- for (i = 0; VEC_iterate (btrace_block_s, btrace, i, block); i++)
- buffer_xml_printf (buffer, "<block begin=\"0x%s\" end=\"0x%s\"/>\n",
- paddress (block->begin), paddress (block->end));
+ for (i = 0;
+ VEC_iterate (btrace_block_s, btrace.variant.bts.blocks, i, block);
+ i++)
+ buffer_xml_printf (buffer, "<block begin=\"0x%s\" end=\"0x%s\"/>\n",
+ paddress (block->begin), paddress (block->end));
- buffer_grow_str0 (buffer, "</btrace>\n");
+ buffer_grow_str0 (buffer, "</btrace>\n");
+ break;
+
+ default:
+ buffer_grow_str0 (buffer, "E.Unknown Trace Format.");
- VEC_free (btrace_block_s, btrace);
+ btrace_data_fini (&btrace);
+ return -1;
+ }
+ btrace_data_fini (&btrace);
return 0;
}
#endif /* HAVE_LINUX_BTRACE */