diff mbox

[2/2] trace: [bsd-user] Commandline arguments to control tracing

Message ID 146651541668.29362.14633530491352662513.stgit@fimbulvetr.bsc.es (mailing list archive)
State New, archived
Headers show

Commit Message

Lluís Vilanova June 21, 2016, 1:23 p.m. UTC
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 bsd-user/main.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Eric Blake June 21, 2016, 10:09 p.m. UTC | #1
On 06/21/2016 07:23 AM, Lluís Vilanova wrote:
> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
>  bsd-user/main.c |   21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/bsd-user/main.c b/bsd-user/main.c
> index 9f592be..ce2cc17 100644
> --- a/bsd-user/main.c
> +++ b/bsd-user/main.c
> @@ -30,6 +30,7 @@
>  #include "qemu/timer.h"
>  #include "qemu/envlist.h"
>  #include "exec/log.h"
> +#include "trace/control.h"
>  
>  int singlestep;
>  unsigned long mmap_min_addr;
> @@ -687,6 +688,14 @@ static void usage(void)
>             "-p pagesize       set the host page size to 'pagesize'\n"
>             "-singlestep       always run in singlestep mode\n"
>             "-strace           log system calls\n"
> +           "-trace-enable name\n"
> +           "                  enable tracing of specified event names\n"
> +           "                  (pass '?' to show a list of events)\n"

Same complaint as in 1/2.  Also, why does this one split into two lines,
while that one had long lines?
Lluís Vilanova June 22, 2016, 9:54 a.m. UTC | #2
Eric Blake writes:

> On 06/21/2016 07:23 AM, Lluís Vilanova wrote:
>> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
>> ---
>> bsd-user/main.c |   21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
>> 
>> diff --git a/bsd-user/main.c b/bsd-user/main.c
>> index 9f592be..ce2cc17 100644
>> --- a/bsd-user/main.c
>> +++ b/bsd-user/main.c
>> @@ -30,6 +30,7 @@
>> #include "qemu/timer.h"
>> #include "qemu/envlist.h"
>> #include "exec/log.h"
>> +#include "trace/control.h"
>> 
>> int singlestep;
>> unsigned long mmap_min_addr;
>> @@ -687,6 +688,14 @@ static void usage(void)
>> "-p pagesize       set the host page size to 'pagesize'\n"
>> "-singlestep       always run in singlestep mode\n"
>> "-strace           log system calls\n"
>> +           "-trace-enable name\n"
>> +           "                  enable tracing of specified event names\n"
>> +           "                  (pass '?' to show a list of events)\n"

> Same complaint as in 1/2.  Also, why does this one split into two lines,
> while that one had long lines?

An oversight on my side.

Thanks,
  Lluis
diff mbox

Patch

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 9f592be..ce2cc17 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -30,6 +30,7 @@ 
 #include "qemu/timer.h"
 #include "qemu/envlist.h"
 #include "exec/log.h"
+#include "trace/control.h"
 
 int singlestep;
 unsigned long mmap_min_addr;
@@ -687,6 +688,14 @@  static void usage(void)
            "-p pagesize       set the host page size to 'pagesize'\n"
            "-singlestep       always run in singlestep mode\n"
            "-strace           log system calls\n"
+           "-trace-enable name\n"
+           "                  enable tracing of specified event names\n"
+           "                  (pass '?' to show a list of events)\n"
+           "-trace-events eventsfile\n"
+           "                  enable tracing of specified event names\n"
+           "                  (one name/pattern per line)\n"
+           "-trace-file tracefile\n"
+           "                  output trace file\n"
            "\n"
            "Environment variables:\n"
            "QEMU_STRACE       Print system calls and arguments similar to the\n"
@@ -735,6 +744,7 @@  int main(int argc, char **argv)
     int gdbstub_port = 0;
     char **target_environ, **wrk;
     envlist_t *envlist = NULL;
+    const char *trace_file = NULL;
     bsd_type = target_openbsd;
 
     if (argc <= 1)
@@ -840,6 +850,12 @@  int main(int argc, char **argv)
             singlestep = 1;
         } else if (!strcmp(r, "strace")) {
             do_strace = 1;
+        } else if (!strcmp(r, "trace-enable")) {
+            trace_enable_events(argv[optind++]);
+        } else if (!strcmp(r, "trace-events")) {
+            trace_init_events(argv[optind++]);
+        } else if (!strcmp(r, "trace-file")) {
+            trace_file = argv[optind++];
         } else
         {
             usage();
@@ -865,6 +881,11 @@  int main(int argc, char **argv)
     }
     filename = argv[optind];
 
+    if (!trace_init_backends()) {
+        exit(1);
+    }
+    trace_init_file(trace_file);
+
     /* Zero out regs */
     memset(regs, 0, sizeof(struct target_pt_regs));