Tracing pull request

-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAl+sCaIACgkQnKSrs4Gr
 c8iIkQf9EY+dublO65TxV4t/VkcB9Z21BNbcCXNF3F+FtkxkGTszrU9t+Vj6k1wL
 hBkhmQZWOjkYq0/UrbpYCFljulStmUM2stHHI6X/E2RDQkBcqZzXzpz1CkXcyHAh
 4UhA+Mgcga3BvhFbkrni8OUI0zNqjw6LBp8CP9woWQWcFlxUmTg+N1RNHH5DpcqZ
 JbVARvSsy6ts6LDC+YUKeDGe8sj2BeOFymYzh0hmxs4msW3GzR7CSR1oP9J2+G3D
 hzRE62RHXG90SaoGxj8HrpZe/NaW3/esAuOcWgmd0Ef/6FE9qoW0GzDGUENsHIDk
 c5XRuLnHlxQ/J4XyvQ2IudhMStjgxw==
 =yulo
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/tracing-pull-request' into staging

Tracing pull request

# gpg: Signature made Wed 11 Nov 2020 15:56:18 GMT
# gpg:                using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35  775A 9CA4 ABB3 81AB 73C8

* remotes/stefanha-gitlab/tags/tracing-pull-request:
  scripts/tracetool: silence SystemTap dtrace(1) long long warnings
  trace: remove argument from trace_init_file

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-11-11 19:53:14 +00:00
commit a4c141dca4
11 changed files with 30 additions and 49 deletions

View File

@ -745,7 +745,6 @@ int main(int argc, char **argv)
const char *gdbstub = NULL; const char *gdbstub = NULL;
char **target_environ, **wrk; char **target_environ, **wrk;
envlist_t *envlist = NULL; envlist_t *envlist = NULL;
char *trace_file = NULL;
bsd_type = target_openbsd; bsd_type = target_openbsd;
if (argc <= 1) if (argc <= 1)
@ -851,8 +850,7 @@ int main(int argc, char **argv)
} else if (!strcmp(r, "strace")) { } else if (!strcmp(r, "strace")) {
do_strace = 1; do_strace = 1;
} else if (!strcmp(r, "trace")) { } else if (!strcmp(r, "trace")) {
g_free(trace_file); trace_opt_parse(optarg);
trace_file = trace_opt_parse(optarg);
} else { } else {
usage(); usage();
} }
@ -880,7 +878,7 @@ int main(int argc, char **argv)
if (!trace_init_backends()) { if (!trace_init_backends()) {
exit(1); exit(1);
} }
trace_init_file(trace_file); trace_init_file();
/* Zero out regs */ /* Zero out regs */
memset(regs, 0, sizeof(struct target_pt_regs)); memset(regs, 0, sizeof(struct target_pt_regs));

View File

@ -386,11 +386,9 @@ static void handle_arg_version(const char *arg)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
static char *trace_file;
static void handle_arg_trace(const char *arg) static void handle_arg_trace(const char *arg)
{ {
g_free(trace_file); trace_opt_parse(arg);
trace_file = trace_opt_parse(arg);
} }
#if defined(TARGET_XTENSA) #if defined(TARGET_XTENSA)
@ -672,7 +670,7 @@ int main(int argc, char **argv, char **envp)
if (!trace_init_backends()) { if (!trace_init_backends()) {
exit(1); exit(1);
} }
trace_init_file(trace_file); trace_init_file();
if (qemu_plugin_load_list(&plugins)) { if (qemu_plugin_load_list(&plugins)) {
exit(1); exit(1);
} }

View File

@ -5466,7 +5466,6 @@ int main(int argc, char **argv)
const img_cmd_t *cmd; const img_cmd_t *cmd;
const char *cmdname; const char *cmdname;
Error *local_error = NULL; Error *local_error = NULL;
char *trace_file = NULL;
int c; int c;
static const struct option long_options[] = { static const struct option long_options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
@ -5516,8 +5515,7 @@ int main(int argc, char **argv)
printf(QEMU_IMG_VERSION); printf(QEMU_IMG_VERSION);
return 0; return 0;
case 'T': case 'T':
g_free(trace_file); trace_opt_parse(optarg);
trace_file = trace_opt_parse(optarg);
break; break;
} }
} }
@ -5535,7 +5533,7 @@ int main(int argc, char **argv)
if (!trace_init_backends()) { if (!trace_init_backends()) {
exit(1); exit(1);
} }
trace_init_file(trace_file); trace_init_file();
qemu_set_log(LOG_TRACE); qemu_set_log(LOG_TRACE);
/* find the command */ /* find the command */

View File

@ -536,7 +536,6 @@ int main(int argc, char **argv)
Error *local_error = NULL; Error *local_error = NULL;
QDict *opts = NULL; QDict *opts = NULL;
const char *format = NULL; const char *format = NULL;
char *trace_file = NULL;
bool force_share = false; bool force_share = false;
#ifdef CONFIG_POSIX #ifdef CONFIG_POSIX
@ -601,8 +600,7 @@ int main(int argc, char **argv)
} }
break; break;
case 'T': case 'T':
g_free(trace_file); trace_opt_parse(optarg);
trace_file = trace_opt_parse(optarg);
break; break;
case 'V': case 'V':
printf("%s version " QEMU_FULL_VERSION "\n" printf("%s version " QEMU_FULL_VERSION "\n"
@ -653,7 +651,7 @@ int main(int argc, char **argv)
if (!trace_init_backends()) { if (!trace_init_backends()) {
exit(1); exit(1);
} }
trace_init_file(trace_file); trace_init_file();
qemu_set_log(LOG_TRACE); qemu_set_log(LOG_TRACE);
/* initialize commands */ /* initialize commands */

View File

@ -581,7 +581,6 @@ int main(int argc, char **argv)
const char *tlscredsid = NULL; const char *tlscredsid = NULL;
bool imageOpts = false; bool imageOpts = false;
bool writethrough = true; bool writethrough = true;
char *trace_file = NULL;
bool fork_process = false; bool fork_process = false;
bool list = false; bool list = false;
int old_stderr = -1; int old_stderr = -1;
@ -768,8 +767,7 @@ int main(int argc, char **argv)
imageOpts = true; imageOpts = true;
break; break;
case 'T': case 'T':
g_free(trace_file); trace_opt_parse(optarg);
trace_file = trace_opt_parse(optarg);
break; break;
case QEMU_NBD_OPT_TLSAUTHZ: case QEMU_NBD_OPT_TLSAUTHZ:
tlsauthz = optarg; tlsauthz = optarg;
@ -816,7 +814,7 @@ int main(int argc, char **argv)
if (!trace_init_backends()) { if (!trace_init_backends()) {
exit(1); exit(1);
} }
trace_init_file(trace_file); trace_init_file();
qemu_set_log(LOG_TRACE); qemu_set_log(LOG_TRACE);
socket_activation = check_socket_activation(); socket_activation = check_socket_activation();

View File

@ -57,6 +57,12 @@ def generate(events, backend, group):
# Avoid it by changing probe type to signed char * beforehand. # Avoid it by changing probe type to signed char * beforehand.
if type_ == 'int8_t *': if type_ == 'int8_t *':
type_ = 'signed char *' type_ = 'signed char *'
# SystemTap dtrace(1) emits a warning when long long is used
type_ = type_.replace('unsigned long long', 'uint64_t')
type_ = type_.replace('signed long long', 'int64_t')
type_ = type_.replace('long long', 'int64_t')
if name in RESERVED_WORDS: if name in RESERVED_WORDS:
name += '_' name += '_'
args.append(type_ + ' ' + name) args.append(type_ + ' ' + name)

View File

@ -884,7 +884,6 @@ int main(int argc, char **argv)
int quiet = 0; int quiet = 0;
int ch; int ch;
Error *local_err = NULL; Error *local_err = NULL;
char *trace_file = NULL;
bool daemonize = false; bool daemonize = false;
bool pidfile_specified = false; bool pidfile_specified = false;
bool socket_path_specified = false; bool socket_path_specified = false;
@ -968,8 +967,7 @@ int main(int argc, char **argv)
++loglevel; ++loglevel;
break; break;
case 'T': case 'T':
g_free(trace_file); trace_opt_parse(optarg);
trace_file = trace_opt_parse(optarg);
break; break;
case 'V': case 'V':
version(argv[0]); version(argv[0]);
@ -992,7 +990,7 @@ int main(int argc, char **argv)
if (!trace_init_backends()) { if (!trace_init_backends()) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
trace_init_file(trace_file); trace_init_file();
qemu_set_log(LOG_TRACE); qemu_set_log(LOG_TRACE);
#ifdef CONFIG_MPATH #ifdef CONFIG_MPATH

View File

@ -2887,7 +2887,6 @@ void qemu_init(int argc, char **argv, char **envp)
int display_remote = 0; int display_remote = 0;
const char *log_mask = NULL; const char *log_mask = NULL;
const char *log_file = NULL; const char *log_file = NULL;
char *trace_file = NULL;
ram_addr_t maxram_size; ram_addr_t maxram_size;
uint64_t ram_slots = 0; uint64_t ram_slots = 0;
FILE *vmstate_dump_file = NULL; FILE *vmstate_dump_file = NULL;
@ -3689,8 +3688,7 @@ void qemu_init(int argc, char **argv, char **envp)
xen_domid_restrict = true; xen_domid_restrict = true;
break; break;
case QEMU_OPTION_trace: case QEMU_OPTION_trace:
g_free(trace_file); trace_opt_parse(optarg);
trace_file = trace_opt_parse(optarg);
break; break;
case QEMU_OPTION_plugin: case QEMU_OPTION_plugin:
qemu_plugin_opt_parse(optarg, &plugin_list); qemu_plugin_opt_parse(optarg, &plugin_list);
@ -3940,7 +3938,7 @@ void qemu_init(int argc, char **argv, char **envp)
if (!trace_init_backends()) { if (!trace_init_backends()) {
exit(1); exit(1);
} }
trace_init_file(trace_file); trace_init_file();
/* Open the logfile at this point and set the log mask if necessary. /* Open the logfile at this point and set the log mask if necessary.
*/ */

View File

@ -180,12 +180,9 @@ static void process_options(int argc, char *argv[])
help(); help();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
case 'T': case 'T':
{ trace_opt_parse(optarg);
char *trace_file = trace_opt_parse(optarg); trace_init_file();
trace_init_file(trace_file); break;
g_free(trace_file);
break;
}
case 'V': case 'V':
printf("qemu-storage-daemon version " printf("qemu-storage-daemon version "
QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n"); QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n");

View File

@ -222,8 +222,10 @@ static void trace_init_events(const char *fname)
loc_pop(&loc); loc_pop(&loc);
} }
void trace_init_file(const char *file) void trace_init_file(void)
{ {
QemuOpts *opts = qemu_find_opts_singleton("trace");
const char *file = qemu_opt_get(opts, "file");
#ifdef CONFIG_TRACE_SIMPLE #ifdef CONFIG_TRACE_SIMPLE
st_set_trace_file(file); st_set_trace_file(file);
if (init_trace_on_startup) { if (init_trace_on_startup) {
@ -289,9 +291,8 @@ bool trace_init_backends(void)
return true; return true;
} }
char *trace_opt_parse(const char *optarg) void trace_opt_parse(const char *optarg)
{ {
char *trace_file;
QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"), QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
optarg, true); optarg, true);
if (!opts) { if (!opts) {
@ -301,11 +302,8 @@ char *trace_opt_parse(const char *optarg)
trace_enable_events(qemu_opt_get(opts, "enable")); trace_enable_events(qemu_opt_get(opts, "enable"));
} }
trace_init_events(qemu_opt_get(opts, "events")); trace_init_events(qemu_opt_get(opts, "events"));
trace_file = g_strdup(qemu_opt_get(opts, "file"));
init_trace_on_startup = true; init_trace_on_startup = true;
qemu_opts_del(opts); qemu_opts_del(opts);
return trace_file;
} }
uint32_t trace_get_vcpu_event_count(void) uint32_t trace_get_vcpu_event_count(void)

View File

@ -167,8 +167,6 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu,
/** /**
* trace_init_backends: * trace_init_backends:
* @file: Name of trace output file; may be NULL.
* Corresponds to commandline option "--trace file=...".
* *
* Initialize the tracing backend. * Initialize the tracing backend.
* *
@ -178,14 +176,12 @@ bool trace_init_backends(void);
/** /**
* trace_init_file: * trace_init_file:
* @file: Name of trace output file; may be NULL.
* Corresponds to commandline option "--trace file=...".
* *
* Record the name of the output file for the tracing backend. * Record the name of the output file for the tracing backend.
* Exits if no selected backend does not support specifying the * Exits if no selected backend does not support specifying the
* output file, and a non-NULL file was passed. * output file, and a file was specified with "-trace file=...".
*/ */
void trace_init_file(const char *file); void trace_init_file(void);
/** /**
* trace_init_vcpu: * trace_init_vcpu:
@ -229,10 +225,8 @@ extern QemuOptsList qemu_trace_opts;
* @optarg: A string argument of --trace command line argument * @optarg: A string argument of --trace command line argument
* *
* Initialize tracing subsystem. * Initialize tracing subsystem.
*
* Returns the filename to save trace to. It must be freed with g_free().
*/ */
char *trace_opt_parse(const char *optarg); void trace_opt_parse(const char *optarg);
/** /**
* trace_get_vcpu_event_count: * trace_get_vcpu_event_count: