diff options
author | Marcin KoĆcielnicki <koriakin@0x04.net> | 2016-02-05 21:32:52 +0100 |
---|---|---|
committer | Marcin KoĆcielnicki <koriakin@0x04.net> | 2016-02-10 23:31:11 +0100 |
commit | 18d3cec54e1b4fce278dba436484846f8048d7d6 (patch) | |
tree | 6e78be8ae681262aef75f4f164d157c62e050e47 /gdb/tracefile-tfile.c | |
parent | 9f6a71b4bfdad8fa2fe33e86f799fa0d362973dc (diff) | |
download | gdb-18d3cec54e1b4fce278dba436484846f8048d7d6.zip gdb-18d3cec54e1b4fce278dba436484846f8048d7d6.tar.gz gdb-18d3cec54e1b4fce278dba436484846f8048d7d6.tar.bz2 |
gdb.trace: Save XML target description in tfile.
gdb/ChangeLog:
* ctf.c (ctf_write_tdesc): New function.
(ctf_write_ops): Wire in ctf_write_tdesc.
* tracefile-tfile.c (tfile_write_tdesc): New function.
(tfile_write_ops): Wire in tfile_write_tdesc.
* tracefile.c (trace_save): Call write_tdesc method.
* tracefile.h (struct trace_file_write_ops): Add write_tdesc method.
* xml-tdesc.c (target_fetch_description_xml): New function.
* xml-tdesc.h: Add target_fetch_description_xml prototype.
Diffstat (limited to 'gdb/tracefile-tfile.c')
-rw-r--r-- | gdb/tracefile-tfile.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c index 8b42aba..c87f61d 100644 --- a/gdb/tracefile-tfile.c +++ b/gdb/tracefile-tfile.c @@ -29,6 +29,7 @@ #include "completer.h" #include "filenames.h" #include "remote.h" +#include "xml-tdesc.h" #ifndef O_LARGEFILE #define O_LARGEFILE 0 @@ -264,6 +265,42 @@ tfile_write_uploaded_tp (struct trace_file_writer *self, } /* This is the implementation of trace_file_write_ops method + write_tdesc. */ + +static void +tfile_write_tdesc (struct trace_file_writer *self) +{ + struct tfile_trace_file_writer *writer + = (struct tfile_trace_file_writer *) self; + char *tdesc = target_fetch_description_xml (¤t_target); + char *ptr = tdesc; + char *next; + + if (tdesc == NULL) + return; + + /* Write tdesc line by line, prefixing each line with "tdesc ". */ + while (ptr != NULL) + { + next = strchr (ptr, '\n'); + if (next != NULL) + { + fprintf (writer->fp, "tdesc %.*s\n", (int) (next - ptr), ptr); + /* Skip the \n. */ + next++; + } + else if (*ptr != '\0') + { + /* Last line, doesn't have a newline. */ + fprintf (writer->fp, "tdesc %s\n", ptr); + } + ptr = next; + } + + xfree (tdesc); +} + +/* This is the implementation of trace_file_write_ops method write_definition_end. */ static void @@ -316,6 +353,7 @@ static const struct trace_file_write_ops tfile_write_ops = tfile_write_status, tfile_write_uploaded_tsv, tfile_write_uploaded_tp, + tfile_write_tdesc, tfile_write_definition_end, tfile_write_raw_data, NULL, |