* [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing
@ 2016-07-15 17:08 Lluís Vilanova
2016-07-15 17:08 ` [Qemu-devel] [PATCH v3 1/2] trace: [linux-user] Commandline " Lluís Vilanova
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Lluís Vilanova @ 2016-07-15 17:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Eric Blake, Stefan Hajnoczi
Adds three commandline arguments to the main *-user programs, following what's
already available in softmmu:
* -trace-enable
* -trace-events
* -trace-file
Changes in v2
=============
* Tell user to use 'help' instead of '?' [Eric Blake].
* Remove newlines on argument docs for bsd-user [Eric Blake].
Changes in v3
=============
* Use new trace_opt_parse() [Stefan Hajnoczi].
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
Lluís Vilanova (2):
trace: [linux-user] Commandline arguments to control tracing
trace: [bsd-user] Commandline arguments to control tracing
bsd-user/main.c | 16 ++++++++++++++++
linux-user/main.c | 19 +++++++++++++++++++
2 files changed, 35 insertions(+)
To: qemu-devel@nongnu.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v3 1/2] trace: [linux-user] Commandline arguments to control tracing
2016-07-15 17:08 [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing Lluís Vilanova
@ 2016-07-15 17:08 ` Lluís Vilanova
2016-07-15 17:08 ` [Qemu-devel] [PATCH v3 2/2] trace: [bsd-user] " Lluís Vilanova
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Lluís Vilanova @ 2016-07-15 17:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Eric Blake, Stefan Hajnoczi, Riku Voipio
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
linux-user/main.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/linux-user/main.c b/linux-user/main.c
index 617a179..53be5dd 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -24,6 +24,7 @@
#include "qapi/error.h"
#include "qemu.h"
#include "qemu/path.h"
+#include "qemu/config-file.h"
#include "qemu/cutils.h"
#include "qemu/help_option.h"
#include "cpu.h"
@@ -33,6 +34,8 @@
#include "qemu/envlist.h"
#include "elf.h"
#include "exec/log.h"
+#include "trace/control.h"
+#include "glib-compat.h"
char *exec_path;
@@ -4001,6 +4004,13 @@ static void handle_arg_version(const char *arg)
exit(EXIT_SUCCESS);
}
+static const char * trace_file = NULL;
+static void handle_arg_trace(const char *arg)
+{
+ g_free((char*)trace_file);
+ trace_file = trace_opt_parse(arg);
+}
+
struct qemu_argument {
const char *argv;
const char *env;
@@ -4048,6 +4058,8 @@ static const struct qemu_argument arg_table[] = {
"", "log system calls"},
{"seed", "QEMU_RAND_SEED", true, handle_arg_randseed,
"", "Seed for pseudo-random number generator"},
+ {"trace", "QEMU_TRACE", true, handle_arg_trace,
+ "", "[[enable=]<pattern>][,events=<file>][,file=<file>]"},
{"version", "QEMU_VERSION", false, handle_arg_version,
"", "display version information and exit"},
{NULL, NULL, false, NULL, NULL, NULL}
@@ -4237,8 +4249,15 @@ int main(int argc, char **argv, char **envp)
srand(time(NULL));
+ qemu_add_opts(&qemu_trace_opts);
+
optind = parse_args(argc, argv);
+ if (!trace_init_backends()) {
+ exit(1);
+ }
+ trace_init_file(trace_file);
+
/* Zero out regs */
memset(regs, 0, sizeof(struct target_pt_regs));
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v3 2/2] trace: [bsd-user] Commandline arguments to control tracing
2016-07-15 17:08 [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing Lluís Vilanova
2016-07-15 17:08 ` [Qemu-devel] [PATCH v3 1/2] trace: [linux-user] Commandline " Lluís Vilanova
@ 2016-07-15 17:08 ` Lluís Vilanova
2016-07-15 19:22 ` Eric Blake
2016-07-15 17:21 ` [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline " Peter Maydell
2016-07-18 12:25 ` Stefan Hajnoczi
3 siblings, 1 reply; 9+ messages in thread
From: Lluís Vilanova @ 2016-07-15 17:08 UTC (permalink / raw)
To: qemu-devel; +Cc: Eric Blake, Stefan Hajnoczi
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
bsd-user/main.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 4819b9e..3bef796 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -21,6 +21,7 @@
#include "qapi/error.h"
#include "qemu.h"
+#include "qemu/config-file.h"
#include "qemu/path.h"
#include "qemu/help_option.h"
/* For tb_lock */
@@ -30,6 +31,8 @@
#include "qemu/timer.h"
#include "qemu/envlist.h"
#include "exec/log.h"
+#include "trace/control.h"
+#include "glib-compat.h"
int singlestep;
unsigned long mmap_min_addr;
@@ -687,6 +690,8 @@ 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=]<pattern>][,events=<file>][,file=<file>]\n"
+ " specify tracing options\n"
"\n"
"Environment variables:\n"
"QEMU_STRACE Print system calls and arguments similar to the\n"
@@ -735,6 +740,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)
@@ -754,6 +760,8 @@ int main(int argc, char **argv)
cpu_model = NULL;
+ qemu_add_opts(&qemu_trace_opts);
+
optind = 1;
for(;;) {
if (optind >= argc)
@@ -840,6 +848,9 @@ int main(int argc, char **argv)
singlestep = 1;
} else if (!strcmp(r, "strace")) {
do_strace = 1;
+ } else if (!strcmp(r, "trace")) {
+ g_free(trace_file);
+ trace_file = trace_opt_parse(optarg);
} else
{
usage();
@@ -865,6 +876,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));
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing
2016-07-15 17:08 [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing Lluís Vilanova
2016-07-15 17:08 ` [Qemu-devel] [PATCH v3 1/2] trace: [linux-user] Commandline " Lluís Vilanova
2016-07-15 17:08 ` [Qemu-devel] [PATCH v3 2/2] trace: [bsd-user] " Lluís Vilanova
@ 2016-07-15 17:21 ` Peter Maydell
2016-07-15 17:48 ` Lluís Vilanova
2016-07-18 12:25 ` Stefan Hajnoczi
3 siblings, 1 reply; 9+ messages in thread
From: Peter Maydell @ 2016-07-15 17:21 UTC (permalink / raw)
To: Lluís Vilanova; +Cc: QEMU Developers, Stefan Hajnoczi
On 15 July 2016 at 18:08, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
> Adds three commandline arguments to the main *-user programs, following what's
> already available in softmmu:
>
> * -trace-enable
> * -trace-events
> * -trace-file
So when would you want to use these rather than the existing
-d trace:pattern and -D logfile options?
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing
2016-07-15 17:21 ` [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline " Peter Maydell
@ 2016-07-15 17:48 ` Lluís Vilanova
2016-07-15 17:49 ` Peter Maydell
0 siblings, 1 reply; 9+ messages in thread
From: Lluís Vilanova @ 2016-07-15 17:48 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, Stefan Hajnoczi
Peter Maydell writes:
> On 15 July 2016 at 18:08, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
>> Adds three commandline arguments to the main *-user programs, following what's
>> already available in softmmu:
>>
>> * -trace-enable
>> * -trace-events
>> * -trace-file
> So when would you want to use these rather than the existing
> -d trace:pattern and -D logfile options?
These are different logs/traces. The ones you point out are textual traces for
TCG guest/target instructions (and where to write them). The ones I've added are
for QEMU's tracing infrastructure.
Note that both (-trace vs -d/-D) are also available in system mode (vl.c).
BTW, I forgot to update the series cover according to v3's changes.
Cheers,
Lluis
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing
2016-07-15 17:48 ` Lluís Vilanova
@ 2016-07-15 17:49 ` Peter Maydell
0 siblings, 0 replies; 9+ messages in thread
From: Peter Maydell @ 2016-07-15 17:49 UTC (permalink / raw)
To: Peter Maydell, QEMU Developers, Stefan Hajnoczi
On 15 July 2016 at 18:48, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
> Peter Maydell writes:
>
>> On 15 July 2016 at 18:08, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
>>> Adds three commandline arguments to the main *-user programs, following what's
>>> already available in softmmu:
>>>
>>> * -trace-enable
>>> * -trace-events
>>> * -trace-file
>
>> So when would you want to use these rather than the existing
>> -d trace:pattern and -D logfile options?
>
> These are different logs/traces. The ones you point out are textual traces for
> TCG guest/target instructions (and where to write them). The ones I've added are
> for QEMU's tracing infrastructure.
-d trace:pattern works for any tracepoint.
> Note that both (-trace vs -d/-D) are also available in system mode (vl.c).
True, so consistency probably makes it worth providing both interfaces.
thanks
-- PMM
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] trace: [bsd-user] Commandline arguments to control tracing
2016-07-15 17:08 ` [Qemu-devel] [PATCH v3 2/2] trace: [bsd-user] " Lluís Vilanova
@ 2016-07-15 19:22 ` Eric Blake
2016-07-18 12:23 ` Stefan Hajnoczi
0 siblings, 1 reply; 9+ messages in thread
From: Eric Blake @ 2016-07-15 19:22 UTC (permalink / raw)
To: Lluís Vilanova, qemu-devel; +Cc: Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 987 bytes --]
On 07/15/2016 11:08 AM, Lluís Vilanova wrote:
> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
> bsd-user/main.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> @@ -754,6 +760,8 @@ int main(int argc, char **argv)
>
> cpu_model = NULL;
>
> + qemu_add_opts(&qemu_trace_opts);
> +
> optind = 1;
> for(;;) {
Optional, but since you are in the area, you could add the missing space
after 'for'.
> if (optind >= argc)
> @@ -840,6 +848,9 @@ int main(int argc, char **argv)
> singlestep = 1;
> } else if (!strcmp(r, "strace")) {
> do_strace = 1;
> + } else if (!strcmp(r, "trace")) {
> + g_free(trace_file);
> + trace_file = trace_opt_parse(optarg);
> } else
> {
and fix the 'else {' to be on one line.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] trace: [bsd-user] Commandline arguments to control tracing
2016-07-15 19:22 ` Eric Blake
@ 2016-07-18 12:23 ` Stefan Hajnoczi
0 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2016-07-18 12:23 UTC (permalink / raw)
To: Eric Blake; +Cc: Lluís Vilanova, qemu-devel, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 1018 bytes --]
On Fri, Jul 15, 2016 at 01:22:54PM -0600, Eric Blake wrote:
> On 07/15/2016 11:08 AM, Lluís Vilanova wrote:
> > Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> > ---
> > bsd-user/main.c | 16 ++++++++++++++++
> > 1 file changed, 16 insertions(+)
> >
>
> > @@ -754,6 +760,8 @@ int main(int argc, char **argv)
> >
> > cpu_model = NULL;
> >
> > + qemu_add_opts(&qemu_trace_opts);
> > +
> > optind = 1;
> > for(;;) {
>
> Optional, but since you are in the area, you could add the missing space
> after 'for'.
>
> > if (optind >= argc)
> > @@ -840,6 +848,9 @@ int main(int argc, char **argv)
> > singlestep = 1;
> > } else if (!strcmp(r, "strace")) {
> > do_strace = 1;
> > + } else if (!strcmp(r, "trace")) {
> > + g_free(trace_file);
> > + trace_file = trace_opt_parse(optarg);
> > } else
> > {
>
> and fix the 'else {' to be on one line.
Done while merging.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing
2016-07-15 17:08 [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing Lluís Vilanova
` (2 preceding siblings ...)
2016-07-15 17:21 ` [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline " Peter Maydell
@ 2016-07-18 12:25 ` Stefan Hajnoczi
3 siblings, 0 replies; 9+ messages in thread
From: Stefan Hajnoczi @ 2016-07-18 12:25 UTC (permalink / raw)
To: Lluís Vilanova; +Cc: qemu-devel, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]
On Fri, Jul 15, 2016 at 07:08:32PM +0200, Lluís Vilanova wrote:
> Adds three commandline arguments to the main *-user programs, following what's
> already available in softmmu:
>
> * -trace-enable
> * -trace-events
> * -trace-file
>
>
> Changes in v2
> =============
>
> * Tell user to use 'help' instead of '?' [Eric Blake].
> * Remove newlines on argument docs for bsd-user [Eric Blake].
>
>
> Changes in v3
> =============
>
> * Use new trace_opt_parse() [Stefan Hajnoczi].
>
>
> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
>
> Lluís Vilanova (2):
> trace: [linux-user] Commandline arguments to control tracing
> trace: [bsd-user] Commandline arguments to control tracing
>
>
> bsd-user/main.c | 16 ++++++++++++++++
> linux-user/main.c | 19 +++++++++++++++++++
> 2 files changed, 35 insertions(+)
>
>
> To: qemu-devel@nongnu.org
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Eric Blake <eblake@redhat.com>
Thank you for quickly rebasing. I have applied the patch and made Eric
Blake's suggested changes. I've also changed linux-user.c "const char *
trace_file" to "char *trace_file" since this heap-allocated string needs
to be freed. The char * type is also used by trace_opt_parse() and
vl.c.
Please remember to run scripts/checkpatch.pl on all patches. The
easiest way to do that is via a git commit hook described here:
http://blog.vmsplice.net/2011/03/how-to-automatically-run-checkpatchpl.html
Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/HEAD
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-07-18 12:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15 17:08 [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline arguments to control tracing Lluís Vilanova
2016-07-15 17:08 ` [Qemu-devel] [PATCH v3 1/2] trace: [linux-user] Commandline " Lluís Vilanova
2016-07-15 17:08 ` [Qemu-devel] [PATCH v3 2/2] trace: [bsd-user] " Lluís Vilanova
2016-07-15 19:22 ` Eric Blake
2016-07-18 12:23 ` Stefan Hajnoczi
2016-07-15 17:21 ` [Qemu-devel] [PATCH v3 0/2] trace: [*-user] Add commandline " Peter Maydell
2016-07-15 17:48 ` Lluís Vilanova
2016-07-15 17:49 ` Peter Maydell
2016-07-18 12:25 ` Stefan Hajnoczi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.