Monitor commands for 'simple' trace backend
cover Monitor commands for 'simple' trace backend
This patchset is based on Stefan's trace framework:
( http://lists.gnu.org/archive/html/qemu-devel/2010-05/msg02407.html )
This adds the following monitor commands for the 'simple' backend:
- trace : to view current contents of the trace buffer
- info tracepoints : to view all available tracepoints and their
state.
- tracepoint NAME on|off: to enable/disable the logging of data from tracepoint 'NAME'.
Signature · 5 lines
Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India
PATCH 1/3 export tdb_hash()
This exports tdb_hash() for use by tracing framework.
--- qdict.c | 2 +- qdict.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletions(-)
qdict.c +1 -1
@@ -56,7 +56,7 @@ QDict *qobject_to_qdict(const QObject *obj)* tdb_hash(): based on the hash agorithm from gdbm, via tdb * (from module-init-tools) */ -static unsigned int tdb_hash (const char *name) +unsigned int tdb_hash (const char *name) {unsigned value;/* Used to compute the hash value. */ unsigned i;/* Used to cycle through random values. */
qdict.h +2 -0
@@ -59,4 +59,6 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t err_value);const char *qdict_get_try_str (const QDict *qdict,const char *key); +/* Export tdb_hash() for use by trace framework */ +unsigned int tdb_hash (const char *name);#endif /* QDICT_H */
Signature · 10 lines
1.6.2.5 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India
Re: [Qemu-devel] [PATCH 1/3] export tdb_hash()
Quoted 1 line · On Tue, 8 Jun 2010 12:31:38 +0530 Prerna Saxena <[email protected]>…
This exports
tdb_hash()for use by tracing framework.
Suggest to rename it (eg. qemu_hash()) and move it to a better location, qdict
is not the best module to export such service.
Quoted 31 lines
Signed-off-by Prerna Saxena <[email protected]>--- qdict.c | 2 +- qdict.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletions(-)qdict.c +1
-1@@ -56,7 +56,7 @@ QDict *qobject_to_qdict(const QObject *obj)* tdb_hash(): based on the hash agorithm from gdbm, via tdb * (from module-init-tools) */ -static unsigned int tdb_hash (const char *name) +unsigned int tdb_hash (const char *name) {unsigned value;/* Used to compute the hash value. */ unsigned i;/* Used to cycle through random values. */ qdict.h +2
-0@@ -59,4 +59,6 @@ int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t err_value);const char *qdict_get_try_str (const QDict *qdict,const char *key); +/* Export tdb_hash() for use by trace framework */ +unsigned int tdb_hash (const char *name);#endif /* QDICT_H */
Re: [Qemu-devel] [PATCH 1/3] export tdb_hash()
Quoted 8 lines · Luiz Capitulino
Quoted 1 line · On Tue, 8 Jun 2010 12:31:38 +0530 Prerna Saxena<[email protected]>…
This exports
tdb_hash()for use by tracing framework.Suggest to rename it (eg.
qemu_hash()) and move it to a better location, qdict
is not the best module to export such service.
Would 'qemu-common.h' be a good place to export it ? If not, any suggestions on where else I can export it ?
I havent renamed it in v2 of patches that I sent out. I'll send out a cumulative patch that renames and exports tdb_hash() from an appropriate location.
Regards,
Signature · 5 lines
Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India
PATCH 2/3 Monitor command 'trace'
In reply to Prerna SaxenaThis introduces the monitor command 'trace' to read current contents of trace buffer.
--- configure | 3 +++ monitor.c | 3 +++ qemu-monitor.hx | 16 ++++++++++++++++ simpletrace.c | 15 +++++++++++++++ tracetool | 4 ++++ 5 files changed, 41 insertions(+), 0 deletions(-)
configure +3 -0
@@ -2302,6 +2302,9 @@ bsd) esac echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak +if test "$trace_backend" = "simple"; then + echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak +fi if test "$trace_backend" = "ust"; then LIBS="-lust $LIBS" fi
monitor.c +3 -0
@@ -55,6 +55,9 @@#include "json-streamer.h" #include "json-parser.h" #include "osdep.h" +#ifdef CONFIG_SIMPLE_TRACE +#include "trace.h" +#endif //#define DEBUG //#define DEBUG_COMPLETION
qemu-monitor.hx +16 -0
@@ -221,6 +221,22 @@ STEXI @item logfile @var{filename} @findex logfile Output logs to @var{filename}. +#ifdef CONFIG_SIMPLE_TRACE +ETEXI + + { + .name = "trace", + .args_type = "", + .params = "", + .help = "shows contents of trace buffer", + .mhandler.cmd = do_info_trace, + }, + +STEXI +@item trace +@findex trace +show contents of trace buffer +#endif ETEXI {
simpletrace.c +15 -0
@@ -62,3 +62,18 @@ void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned longvoid trace5 (TraceEvent event,unsigned long x1,unsigned long x2,unsigned long x3,unsigned long x4,unsigned long x5) {trace (event, x1, x2, x3, x4, x5); } + +void do_info_trace (Monitor *mon) { +static unsigned int i, max_idx; + +if (trace_idx) + max_idx = trace_idx; +else + max_idx =TRACE_BUF_LEN ; + +for (i=0 ; i<max_idx ;i++) +monitor_printf (mon,"Event %ld : %ld %ld %ld %ld %ld\n" , + trace_buf[i].event, trace_buf[i].x1, trace_buf[i].x2, + trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5); +return ; +}
tracetool +4 -0
@@ -130,6 +130,7 @@ void trace2(TraceEvent event, unsigned long x1, unsigned long x2); void trace3(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3); void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4); void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5); +void do_info_trace(Monitor *mon); EOF simple_event_num=0
@@ -289,6 +290,9 @@ tracetoh() #define TRACE_H #include "qemu-common.h" + +extern void monitor_printf(Monitor *mon, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); EOF convert h echo "#endif /* TRACE_H */"
Signature · 10 lines
1.6.2.5 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India
Re: [Qemu-devel] [PATCH 2/3] Monitor command 'trace'
Quoted 73 lines · On Tue, 8 Jun 2010 12:34:37 +0530 Prerna Saxena <[email protected]>…
This introduces the monitor command 'trace' to read current contents of trace buffer.
Signed-off-by Prerna Saxena <[email protected]>--- configure | 3 +++ monitor.c | 3 +++ qemu-monitor.hx | 16 ++++++++++++++++ simpletrace.c | 15 +++++++++++++++ tracetool | 4 ++++ 5 files changed, 41 insertions(+), 0 deletions(-)configure +3
-0@@ -2302,6 +2302,9 @@ bsd) esac echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak +if test "$trace_backend" = "simple"; then + echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak +fi if test "$trace_backend" = "ust"; then LIBS="-lust $LIBS" fimonitor.c +3
-0@@ -55,6 +55,9 @@#include "json-streamer.h" #include "json-parser.h" #include "osdep.h" +#ifdef CONFIG_SIMPLE_TRACE +#include "trace.h" +#endif //#define DEBUG //#define DEBUG_COMPLETION qemu-monitor.hx +16
-0@@ -221,6 +221,22 @@ STEXI @item logfile @var{filename} @findex logfile Output logs to @var{filename}. +#ifdef CONFIG_SIMPLE_TRACE +ETEXI + + { + .name = "trace", + .args_type = "", + .params = "", + .help = "shows contents of trace buffer", + .mhandler.cmd = do_info_trace, + }, + +STEXI +@item trace +@findex trace +show contents of trace buffer +#endif ETEXI {simpletrace.c +0
-0
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 66
Quoted 5 lines
simpletrace.c +2
-0@@ -62,3 +62,18 @@ void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned longvoid trace5 (TraceEvent event,unsigned long x1,unsigned long x2,unsigned long x3,unsigned long x4,unsigned long x5) {trace (event, x1, x2, x3, x4, x5); } + +void do_info_trace (Monitor *mon) {
You sure this shouldn't be 'info trace'?
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 67
Quoted 1 line
simpletrace.c +1
-0+static unsigned int i, max_idx;
Why static?
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 72
Quoted 5 lines
simpletrace.c +5
-0+ +if (trace_idx) + max_idx = trace_idx; +else + max_idx =TRACE_BUF_LEN ;
max_idx = trace_idx ? trace_idx : TRACE_BUF_LEN;
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 77
Quoted 5 lines
simpletrace.c +5
-0+ +for (i=0 ; i<max_idx ;i++) +monitor_printf (mon,"Event %ld : %ld %ld %ld %ld %ld\n" , + trace_buf[i].event, trace_buf[i].x1, trace_buf[i].x2, + trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5);
Style & indentation.
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 78
Quoted 1 line
simpletrace.c +1
-0+return ;
Not needed.
Quoted 23 lines
simpletrace.c +1
-0+}tracetool +4
-0@@ -130,6 +130,7 @@ void trace2(TraceEvent event, unsigned long x1, unsigned long x2); void trace3(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3); void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4); void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5); +void do_info_trace(Monitor *mon); EOF simple_event_num=0@@ -289,6 +290,9 @@ tracetoh() #define TRACE_H #include "qemu-common.h" + +extern void monitor_printf(Monitor *mon, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); EOF convert h echo "#endif /* TRACE_H */"
Re: [Qemu-devel] [PATCH 2/3] Monitor command 'trace'
Hi Luiz,
Thanks for your feedback.
Quoted 6 lines · Luiz Capitulino
Quoted 3 lines · On Tue, 8 Jun 2010 12:34:37 +0530 Prerna Saxena<[email protected]>…
This introduces the monitor command 'trace' to read current contents of trace buffer.
Quoted 13 lines
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 66
Quoted 11 lines
...
simpletrace.c +2
-0@@ -62,3 +62,18 @@ void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned longvoid trace5 (TraceEvent event,unsigned long x1,unsigned long x2,unsigned long x3,unsigned long x4,unsigned long x5) {trace (event, x1, x2, x3, x4, x5); } + +void do_info_trace (Monitor *mon) {You sure this shouldn't be 'info trace'?
In this set, I had a direct monitor command 'trace' to display trace buffer contents.
In v2, I have introduced an 'info trace' command to do the same, since it intuitively made more sense to use an 'info' command to see state of trace buffer. For this implementation, the present handler name makes more sense.(do_info_trace())
Quoted 4 lines
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 67
Quoted 2 lines
simpletrace.c +1
-0+static unsigned int i, max_idx;Why static?
This isnt needed. The next patch in this series removed it (This change should've been a part of this patch, but went into next) Cleaned it up in v2.
Quoted 9 lines
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 72
Quoted 6 lines
simpletrace.c +5
-0+ +if (trace_idx) + max_idx = trace_idx; +else + max_idx =TRACE_BUF_LEN ;max_idx = trace_idx ? trace_idx : TRACE_BUF_LEN;
Quoted 7 lines
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 77
Quoted 5 lines
simpletrace.c +5
-0+ +for (i=0 ; i<max_idx ;i++) +monitor_printf (mon,"Event %ld : %ld %ld %ld %ld %ld\n" , + trace_buf[i].event, trace_buf[i].x1, trace_buf[i].x2, + trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5);Style& indentation.
Changed in v2.
Quoted 4 lines
simpletrace.c void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long · line 78
Quoted 2 lines
simpletrace.c +1
-0+return ;Not needed.
Removed in v2.
Quoted 6 lines
Quoted 4 lines
simpletrace.c +1
-0+}tracetool +0
-0
Signature · 5 lines
Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India
PATCH 3/3 Toggle tracepoint state
In reply to Prerna SaxenaThis patch adds support for dynamically enabling/disabling of tracepoints. Monitor commands added :
1) info tracepoints : to view all available tracepoints and
their state.
2) tracepoint NAME on|off : to enable/disable data logging from a
given tracepoint.
Eg, tracepoint paio_submit off
disables logging of data when paio_submit is hit.
At present this is done with a simple comparison -- there is scope for optimizations that can be employed here to speed this up.
--- monitor.c | 21 +++++++++++++++++++++ qemu-monitor.hx | 16 ++++++++++++++++ simpletrace.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- tracetool | 30 ++++++++++++++++++++++++++---- vl.c | 6 ++++++ 5 files changed, 123 insertions(+), 5 deletions(-)
monitor.c +21 -0
@@ -547,7 +547,19 @@ static void do_commit(Monitor *mon, const QDict *qdict)bdrv_commit (dinfo->bdrv); } } +#ifdef CONFIG_SIMPLE_TRACE +static void do_change_tracepoint_state (Monitor *mon,const QDict *qdict) +{ +const char *tp_name =qdict_get_str (qdict,"name" ); +const char *tp_state =qdict_get_str (qdict,"option" ); +if (!strncmp (tp_state,"on" ,2 )) +change_tracepoint_state (tp_name,1 ); +if (!strncmp (tp_state,"off" ,3 )) +change_tracepoint_state (tp_name,0 ); +return ; +} +#endif static void user_monitor_complete (void *opaque,QObject *ret_data) {MonitorCompletionData *data = (MonitorCompletionData *)opaque;
@@ -2783,6 +2795,15 @@ static const mon_cmd_t info_cmds[] = { .help = "show roms", .mhandler.info = do_info_roms, }, +#ifdef CONFIG_SIMPLE_TRACE + { + .name = "tracepoints", + .args_type = "", + .params = "", + .help = "show available tracepoints & their state", + .mhandler.info = do_info_all_tracepoints, + }, +#endif { .name = NULL, },
qemu-monitor.hx +16 -0
@@ -114,6 +114,8 @@ show migration status show balloon information @item info qtree show device tree +@item info tracepoints +show available tracepoints and their state @end table ETEXI
@@ -236,6 +238,20 @@ STEXI @item trace @findex trace show contents of trace buffer +ETEXI + + { + .name = "tracepoint", + .args_type = "name:s,option:s", + .params = "name on|off", + .help = "changes status of a specific tracepoint", + .mhandler.cmd = do_change_tracepoint_state, + }, + +STEXI +@item tracepoint +@findex tracepoint +changes status of a tracepoint #endif ETEXI
simpletrace.c +54 -1
80 lines not on this page · raw message
tracetool +26 -4
@@ -123,14 +123,20 @@ linetoc_end_nop() linetoh_begin_simple() { cat <<EOF +#include <stdbool.h> + typedef unsigned int TraceEvent; +void init_tracepoint_table(void); +void init_tracepoint(const char *tname, TraceEvent tevent); void trace1(TraceEvent event, unsigned long x1); void trace2(TraceEvent event, unsigned long x1, unsigned long x2); void trace3(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3); void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4); void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5); void do_info_trace(Monitor *mon); +void do_info_all_tracepoints(Monitor *mon); +void change_tracepoint_state(const char *tname, bool tstate); EOF simple_event_num=0
@@ -163,22 +169,38 @@ EOF linetoh_end_simple() { - return + cat <<EOF +#define NR_TRACEPOINTS $simple_event_num +EOF } linetoc_begin_simple() { - return + cat <<EOF +#include "trace.h" + +void init_tracepoint_table(void) { +EOF + simple_event_num=0 + } linetoc_simple() { - return + local name + name=$(get_name "$1") + cat <<EOF +init_tracepoint("$name", $simple_event_num); +EOF + simple_event_num=$((simple_event_num + 1)) } linetoc_end_simple() { - return + cat <<EOF +return; +} +EOF } linetoh_begin_ust()
vl.c +6 -0
@@ -163,6 +163,9 @@ int main(int argc, char **argv)#include "cpus.h" #include "arch_init.h" +#ifdef CONFIG_SIMPLE_TRACE +#include "trace.h" +#endif //#define DEBUG_NET //#define DEBUG_SLIRP
@@ -3604,6 +3607,9 @@ int main(int argc, char **argv, char **envp)if (net_init_clients () <0 ) {exit (1 ); } +#ifdef CONFIG_SIMPLE_TRACE +init_tracepoint_table (); +#endif /* init the bluetooth world */ if (foreach_device_config (DEV_BT , bt_parse))
Signature · 10 lines
1.6.2.5 -- Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India
Re: [Qemu-devel] [PATCH 3/3] Toggle tracepoint state
Quoted 30 lines · On Tue, 8 Jun 2010 12:38:58 +0530 Prerna Saxena <[email protected]>…
This patch adds support for dynamically enabling/disabling of tracepoints. Monitor commands added :
1) info tracepoints : to view all available tracepoints and
their state.
2) tracepoint NAME on|off : to enable/disable data logging from a
given tracepoint.
Eg, tracepointpaio_submitoff
disables logging of data whenpaio_submitis hit.At present this is done with a simple comparison -- there is scope for optimizations that can be employed here to speed this up.
Signed-off-by Prerna Saxena <[email protected]>--- monitor.c | 21 +++++++++++++++++++++ qemu-monitor.hx | 16 ++++++++++++++++ simpletrace.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- tracetool | 30 ++++++++++++++++++++++++++---- vl.c | 6 ++++++ 5 files changed, 123 insertions(+), 5 deletions(-)monitor.c +0
-0@@ -547,7 +547,19 @@ static void do_commit(Monitor *mon, const QDict *qdict)bdrv_commit (dinfo->bdrv); } }
monitor.c static void do_commit(Monitor *mon, const QDict *qdict) · line 559
Quoted 10 lines
monitor.c +9
-0+#ifdef CONFIG_SIMPLE_TRACE +static void do_change_tracepoint_state (Monitor *mon,const QDict *qdict) +{ +const char *tp_name =qdict_get_str (qdict,"name" ); +const char *tp_state =qdict_get_str (qdict,"option" ); +if (!strncmp (tp_state,"on" ,2 )) +change_tracepoint_state (tp_name,1 ); +if (!strncmp (tp_state,"off" ,3 )) +change_tracepoint_state (tp_name,0 );
Monitor has a bool type, please take a look in do_set_link().
monitor.c static void do_commit(Monitor *mon, const QDict *qdict) · line 560
Quoted 1 line
monitor.c +1
-0+return ;
Not needed, also true for other functions in this patch, suggest readingCODING_STYLE for other style related issues in this series.
Quoted 235 lines
monitor.c +11
-0+} +#endif static void user_monitor_complete (void *opaque,QObject *ret_data) {MonitorCompletionData *data = (MonitorCompletionData *)opaque;@@ -2783,6 +2795,15 @@ static const mon_cmd_t info_cmds[] = { .help = "show roms", .mhandler.info = do_info_roms, }, +#ifdef CONFIG_SIMPLE_TRACE + { + .name = "tracepoints", + .args_type = "", + .params = "", + .help = "show available tracepoints & their state", + .mhandler.info = do_info_all_tracepoints, + }, +#endif { .name = NULL, },qemu-monitor.hx +16
-0@@ -114,6 +114,8 @@ show migration status show balloon information @item info qtree show device tree +@item info tracepoints +show available tracepoints and their state @end table ETEXI@@ -236,6 +238,20 @@ STEXI @item trace @findex trace show contents of trace buffer +ETEXI + + { + .name = "tracepoint", + .args_type = "name:s,option:s", + .params = "name on|off", + .help = "changes status of a specific tracepoint", + .mhandler.cmd = do_change_tracepoint_state, + }, + +STEXI +@item tracepoint +@findex tracepoint +changes status of a tracepoint #endif ETEXIsimpletrace.c +54
-1@@ -3,6 +3,12 @@#include "trace.h" typedef struct { +char *tp_name; +bool state; +unsigned int hash; +}Tracepoint ; + +typedef struct { unsigned long event; unsigned long x1; unsigned long x2;@@ -18,10 +24,24 @@ enum {static TraceRecord trace_buf[TRACE_BUF_LEN ];static unsigned int trace_idx;static FILE *trace_fp; +static Tracepoint trace_list[NR_TRACEPOINTS ]; + +void init_tracepoint (const char *tname,TraceEvent tevent) { +if (!tname || tevent >NR_TRACEPOINTS ) +return ; + + trace_list[tevent].tp_name = (char *)qemu_malloc (strlen (tname)+1 ); +strncpy (trace_list[tevent].tp_name, tname,strlen (tname)); + trace_list[tevent].hash =tdb_hash (tname); + trace_list[tevent].state =1 ;/* Enable all by default */ +return ; +}static void trace (TraceEvent event,unsigned long x1,unsigned long x2,unsigned long x3,unsigned long x4,unsigned long x5) { +if (!trace_list[event].state) +return ;TraceRecord *rec = &trace_buf[trace_idx]; rec->event = event; rec->x1 = x1;@@ -64,7 +84,7 @@ void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long }void do_info_trace (Monitor *mon) { -static unsigned int i, max_idx; +unsigned int i, max_idx;if (trace_idx) max_idx = trace_idx;@@ -77,3 +97,36 @@ void do_info_trace(Monitor *mon) { trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5);return ; } + +void do_info_all_tracepoints (Monitor *mon) { +unsigned int i; +for (i=0 ; i<NR_TRACEPOINTS ; i++) +monitor_printf (mon,"%s [Event ID %u] : state %u\n" , + trace_list[i].tp_name, i, trace_list[i].state); +return ; +} + +static int find_tracepoint_by_name (const char *tname) { +unsigned int i, name_hash; + +if (!tname) +return -1 ; + + name_hash =tdb_hash (tname); + +for (i=0 ; i<NR_TRACEPOINTS ; i++) +if (trace_list[i].hash == name_hash && + !strncmp (trace_list[i].tp_name, tname,strlen (tname))) +return i; +return -1 ;/* indicates end of list reached without a match */ +} + +void change_tracepoint_state (const char *tname,bool tstate) { +int i; + + i =find_tracepoint_by_name (tname); +/* TODO : This update might need to be protected by a memory barrier */ +if (i >=0 ) + trace_list[i].state = tstate; +return ; +}tracetool +26
-4@@ -123,14 +123,20 @@ linetoc_end_nop() linetoh_begin_simple() { cat <<EOF +#include <stdbool.h> + typedef unsigned int TraceEvent; +void init_tracepoint_table(void); +void init_tracepoint(const char *tname, TraceEvent tevent); void trace1(TraceEvent event, unsigned long x1); void trace2(TraceEvent event, unsigned long x1, unsigned long x2); void trace3(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3); void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4); void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5); void do_info_trace(Monitor *mon); +void do_info_all_tracepoints(Monitor *mon); +void change_tracepoint_state(const char *tname, bool tstate); EOF simple_event_num=0@@ -163,22 +169,38 @@ EOF linetoh_end_simple() { - return + cat <<EOF +#define NR_TRACEPOINTS $simple_event_num +EOF } linetoc_begin_simple() { - return + cat <<EOF +#include "trace.h" + +void init_tracepoint_table(void) { +EOF + simple_event_num=0 + } linetoc_simple() { - return + local name + name=$(get_name "$1") + cat <<EOF +init_tracepoint("$name", $simple_event_num); +EOF + simple_event_num=$((simple_event_num + 1)) } linetoc_end_simple() { - return + cat <<EOF +return; +} +EOF } linetoh_begin_ust()vl.c +6
-0@@ -163,6 +163,9 @@ int main(int argc, char **argv)#include "cpus.h" #include "arch_init.h" +#ifdef CONFIG_SIMPLE_TRACE +#include "trace.h" +#endif //#define DEBUG_NET //#define DEBUG_SLIRP @@ -3604,6 +3607,9 @@ int main(int argc, char **argv, char **envp)if (net_init_clients () <0 ) {exit (1 ); } +#ifdef CONFIG_SIMPLE_TRACE +init_tracepoint_table (); +#endif /* init the bluetooth world */ if (foreach_device_config (DEV_BT , bt_parse))
Re: [Qemu-devel] [PATCH 3/3] Toggle tracepoint state
Hi Luiz,
Thanks for taking time to review it.
Quoted 10 lines · Luiz Capitulino
Quoted 4 lines · On Tue, 8 Jun 2010 12:38:58 +0530 Prerna Saxena<[email protected]>…
This patch adds support for dynamically enabling/disabling of tracepoints. Monitor commands added :
....Monitor has a bool type, please take a look in
do_set_link().
Thanks for the pointer. Changed in v2.
Quoted 4 lines
Quoted 1 line
+ return;
Not needed, also true for other functions in this patch, suggest reading
CODING_STYLEfor other style related issues in this series.
Done.
Quoted 3 lines
Quoted 3 lines
....
Hope these commands would make it easy to visualize logged traces via the monitor. I'd appreciate feedback on how v2 of the patches posted can be enhanced.
Signature · 5 lines
Prerna Saxena Linux Technology Centre, IBM Systems and Technology Lab, Bangalore, India