From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22981 invoked by alias); 26 Jun 2013 08:03:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 22969 invoked by uid 89); 26 Jun 2013 08:03:05 -0000 X-Spam-SWARE-Status: No, score=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_CP,TW_VN autolearn=ham version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 26 Jun 2013 08:03:03 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1Urkgv-0002dB-AX from Yao_Qi@mentor.com ; Wed, 26 Jun 2013 01:03:01 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 26 Jun 2013 01:03:00 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Wed, 26 Jun 2013 01:03:00 -0700 Message-ID: <51CAA012.5040106@codesourcery.com> Date: Wed, 26 Jun 2013 08:19:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Pedro Alves CC: Subject: Re: [PATCH 4/6] Add id of TSV into traceframe_info. References: <1370610493-26468-1-git-send-email-yao@codesourcery.com> <1371086914-8398-1-git-send-email-yao@codesourcery.com> <1371086914-8398-5-git-send-email-yao@codesourcery.com> <51C9BEC4.5070503@redhat.com> In-Reply-To: <51C9BEC4.5070503@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-SW-Source: 2013-06/txt/msg00759.txt.bz2 On 06/26/2013 12:01 AM, Pedro Alves wrote: > The VEC holds "int", so this passing through int32_looks a > little odd. And why uint64, if the id is always written > as int32 ? > babeltrace has two APIs to access integers bt_ctf_get_uint64 and bt_ctf_get_int64. We have to use them to read 32-bit integer. In the updated patch, I define "vnum" with type "int" and use bt_ctf_get_int64 to read it from ctf trace. > Both are written as int32_t: > > ... > /* number */ > ctf_save_write_int32 (&writer->tcs, tsv->number); > ... > static void > ctf_write_frame_v_block (struct trace_file_writer *self, > int32_t num, uint64_t val) > { > ... > /* num. */ > ctf_save_align_write (&writer->tcs, (gdb_byte *) &num, 4, 4); > ... > > > BTW, this made me look at the ctf definitions, and I notice that: > > ctf_save_write_metadata (&writer->tcs, "\n"); > ctf_save_write_metadata (&writer->tcs, > "event {\n\tname = \"tsv_def\";\n" > "\tid = %u;\n\tfields := struct { \n" > "\t\tint64_t initial_value;\n" > "\t\tint32_t number;\n" > "\t\tint32_t builtin;\n" > "\t\tchars name;\n" > "\t};\n" > "};\n", CTF_EVENT_ID_TSV_DEF); > > "number" here is int32_t, but here > > ctf_save_write_metadata (&writer->tcs, "\n"); > ctf_save_write_metadata (&writer->tcs, > "event {\n\tname = \"tsv\";\n\tid = %u;\n" > "\tfields := struct { \n" > "\t\tuint64_t val;\n" > "\t\tuint32_t num;\n" > "\t};\n" > "};\n", CTF_EVENT_ID_TSV); > > > "num" is uint32_t. Thanks for pointing this out. "num" should be int32_t here. I'll fix it separately. > > Otherwise this is OK. Patch below is what I committed. -- Yao (齐尧) gdb: 2013-06-26 Pedro Alves Yao Qi * ctf.c (ctf_traceframe_info): Push trace state variables present in the trace data into the traceframe info object. * breakpoint.c (DEF_VEC_I): Remove. * common/filestuff.c (DEF_VEC_I): Likewise. * dwarf2loc.c (DEF_VEC_I): Likewise. * mi/mi-main.c (DEF_VEC_I): Likewise. * common/gdb_vecs.h (DEF_VEC_I): Define vector for int. * features/traceframe-info.dtd: Add tvar element and its attributes. * tracepoint.c (free_traceframe_info): Free vector 'tvars'. (build_traceframe_info): Push trace state variables present in the trace data into the traceframe info object. (traceframe_info_start_tvar): New function. (tvar_attributes): New. (traceframe_info_children): Add "tvar" element. * tracepoint.h (struct traceframe_info) : New field. * NEWS: Mention the change in GDB and GDBserver. gdb/doc: 2013-06-26 Pedro Alves * gdb.texinfo (Traceframe Info Format): Document tvar element and its attributes. gdb/gdbserver: 2013-06-26 Pedro Alves * tracepoint.c (build_traceframe_info_xml): Output trace state variables present in the trace buffer. --- gdb/NEWS | 7 +++++++ gdb/breakpoint.c | 2 -- gdb/common/filestuff.c | 2 -- gdb/common/gdb_vecs.h | 2 ++ gdb/ctf.c | 12 ++++++++++++ gdb/doc/gdb.texinfo | 12 +++++++++++- gdb/dwarf2loc.c | 2 -- gdb/features/traceframe-info.dtd | 5 ++++- gdb/gdbserver/tracepoint.c | 7 +++++++ gdb/mi/mi-main.c | 2 -- gdb/tracepoint.c | 30 ++++++++++++++++++++++++++++++ gdb/tracepoint.h | 3 +++ 12 files changed, 76 insertions(+), 10 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index b86e8d8..ab8f283 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -92,6 +92,9 @@ show range-stepping the number of control packets from/to GDB. See "New remote packets" below. +* GDB now understands the element 'tvar' in the XML traceframe info. + It has the id of the collected trace state variables. + * New remote packets vCont;r @@ -113,6 +116,10 @@ qXfer:libraries-svr4:read's annex ** GDBserver now supports target-assisted range stepping. Currently enabled on x86/x86_64 GNU/Linux targets. + ** GDBserver now adds element 'tvar' in the XML in the reply to + 'qXfer:traceframe-info:read'. It has the id of the collected + trace state variables. + *** Changes in GDB 7.6 * Target record has been renamed to record-full. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ccd05d9..af6a42a 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5799,8 +5799,6 @@ bptype_string (enum bptype type) return bptypes[(int) type].description; } -DEF_VEC_I(int); - /* For MI, output a field named 'thread-groups' with a list as the value. For CLI, prefix the list with the string 'inf'. */ diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c index daf96d9..7d1a69a 100644 --- a/gdb/common/filestuff.c +++ b/gdb/common/filestuff.c @@ -157,8 +157,6 @@ fdwalk (int (*func) (void *, int), void *arg) don't use a hashtab because libiberty isn't linked into gdbserver; and anyway we don't expect there to be many open fds. */ -DEF_VEC_I (int); - static VEC (int) *open_fds; /* An fdwalk callback function used by notice_open_fds. It puts the diff --git a/gdb/common/gdb_vecs.h b/gdb/common/gdb_vecs.h index 1b05b0c..7df3001 100644 --- a/gdb/common/gdb_vecs.h +++ b/gdb/common/gdb_vecs.h @@ -29,6 +29,8 @@ DEF_VEC_P (char_ptr); DEF_VEC_P (const_char_ptr); +DEF_VEC_I (int); + extern void free_char_ptr_vec (VEC (char_ptr) *char_ptr_vec); extern struct cleanup * diff --git a/gdb/ctf.c b/gdb/ctf.c index 278f950..23ee36d 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -1778,6 +1778,18 @@ ctf_traceframe_info (void) def = bt_ctf_get_field (event, scope, "length"); r->length = (uint16_t) bt_ctf_get_uint64 (def); } + else if (strcmp (name, "tsv") == 0) + { + int vnum; + const struct bt_definition *scope + = bt_ctf_get_top_level_scope (event, + BT_EVENT_FIELDS); + const struct bt_definition *def; + + def = bt_ctf_get_field (event, scope, "num"); + vnum = (int) bt_ctf_get_int64 (def); + VEC_safe_push (int, info->tvars, vnum); + } else { warning (_("Unhandled trace block type (%s) " diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index d25cdae..3992704 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -41789,17 +41789,27 @@ A region of collected memory starting at @var{addr} and extending for @end smallexample +@item +A block indicating trace state variable numbered @var{number} has been +collected: + +@smallexample + +@end smallexample + @end itemize The formal DTD for the traceframe info format is given below: @smallexample - + + + @end smallexample @node Branch Trace Format diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index bb600d1..02afcdf 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -42,8 +42,6 @@ #include "gdb_string.h" #include "gdb_assert.h" -DEF_VEC_I(int); - extern int dwarf2_always_disassemble; static void dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc, diff --git a/gdb/features/traceframe-info.dtd b/gdb/features/traceframe-info.dtd index 0da2bec..b811122 100644 --- a/gdb/features/traceframe-info.dtd +++ b/gdb/features/traceframe-info.dtd @@ -5,9 +5,12 @@ notice and this notice are preserved. --> - + + + + diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index d237e7f..6492b5a 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -5401,6 +5401,13 @@ build_traceframe_info_xml (char blocktype, unsigned char *dataptr, void *data) break; } case 'V': + { + int vnum; + + memcpy (&vnum, dataptr, sizeof (vnum)); + buffer_xml_printf (buffer, "\n", vnum); + break; + } case 'R': case 'S': { diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 127f6ff..430d530 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -513,8 +513,6 @@ mi_cmd_thread_info (char *command, char **argv, int argc) print_thread_info (current_uiout, argv[0], -1); } -DEF_VEC_I(int); - struct collect_cores_data { int pid; diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 61e9efa..62b1a2c 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -235,6 +235,7 @@ free_traceframe_info (struct traceframe_info *info) if (info != NULL) { VEC_free (mem_range_s, info->memory); + VEC_free (int, info->tvars); xfree (info); } @@ -5224,6 +5225,12 @@ build_traceframe_info (char blocktype, void *data) break; } case 'V': + { + int vnum; + + tfile_read ((gdb_byte *) &vnum, 4); + VEC_safe_push (int, info->tvars, vnum); + } case 'R': case 'S': { @@ -5581,6 +5588,21 @@ traceframe_info_start_memory (struct gdb_xml_parser *parser, r->length = *length_p; } +/* Handle the start of a element. */ + +static void +traceframe_info_start_tvar (struct gdb_xml_parser *parser, + const struct gdb_xml_element *element, + void *user_data, + VEC(gdb_xml_value_s) *attributes) +{ + struct traceframe_info *info = user_data; + const char *id_attrib = xml_find_attribute (attributes, "id")->value; + int id = gdb_xml_parse_ulongest (parser, id_attrib); + + VEC_safe_push (int, info->tvars, id); +} + /* Discard the constructed trace frame info (if an error occurs). */ static void @@ -5599,10 +5621,18 @@ static const struct gdb_xml_attribute memory_attributes[] = { { NULL, GDB_XML_AF_NONE, NULL, NULL } }; +static const struct gdb_xml_attribute tvar_attributes[] = { + { "id", GDB_XML_AF_NONE, NULL, NULL }, + { NULL, GDB_XML_AF_NONE, NULL, NULL } +}; + static const struct gdb_xml_element traceframe_info_children[] = { { "memory", memory_attributes, NULL, GDB_XML_EF_REPEATABLE | GDB_XML_EF_OPTIONAL, traceframe_info_start_memory, NULL }, + { "tvar", tvar_attributes, NULL, + GDB_XML_EF_REPEATABLE | GDB_XML_EF_OPTIONAL, + traceframe_info_start_tvar, NULL }, { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL } }; diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h index 3b09ca8..350ab5e 100644 --- a/gdb/tracepoint.h +++ b/gdb/tracepoint.h @@ -30,6 +30,9 @@ struct traceframe_info { /* Collected memory. */ VEC(mem_range_s) *memory; + + /* Collected trace state variables. */ + VEC(int) *tvars; }; /* A trace state variable is a value managed by a target being -- 1.7.7.6