]> granicus.if.org Git - strace/blobdiff - strace.c
tests: check decoding of vcpu auxstr
[strace] / strace.c
index 8143cadb21ddd25836b9dbded8a6c06dfa3541e9..467e8a6eb9609b72cf5143fd8f2a8e00c5a45103 100644 (file)
--- a/strace.c
+++ b/strace.c
@@ -278,7 +278,11 @@ Statistics:\n\
 \n\
 Filtering:\n\
   -e expr        a qualifying expression: option=[!]all or option=[!]val1[,val2]...\n\
-     options:    trace, abbrev, verbose, raw, signal, read, write, fault\n\
+     options:    trace, abbrev, verbose, raw, signal, read, write, fault"
+#ifdef HAVE_LINUX_KVM_H
+              ", kvm"
+#endif
+"\n\
   -P path        trace accesses to path\n\
 \n\
 Tracing:\n\
@@ -421,7 +425,8 @@ set_cloexec_flag(int fd)
        if (flags == newflags)
                return;
 
-       fcntl(fd, F_SETFD, newflags); /* never fails */
+       if (fcntl(fd, F_SETFD, newflags)) /* never fails */
+               perror_msg_and_die("fcntl(%d, F_SETFD, %#x)", fd, newflags);
 }
 
 static void
@@ -715,6 +720,11 @@ after_successful_attach(struct tcb *tcp, const unsigned int flags)
                xsprintf(name, "%s.%u", outfname, tcp->pid);
                tcp->outf = strace_fopen(name);
        }
+
+#ifdef ENABLE_STACKTRACE
+       if (stack_trace_enabled)
+               unwind_tcb_init(tcp);
+#endif
 }
 
 static void
@@ -756,12 +766,6 @@ alloctcb(int pid)
 #if SUPPORTED_PERSONALITIES > 1
                        tcp->currpers = current_personality;
 #endif
-
-#ifdef ENABLE_STACKTRACE
-                       if (stack_trace_enabled)
-                               unwind_tcb_init(tcp);
-#endif
-
                        nprocs++;
                        debug_msg("new tcb for pid %d, active tcbs:%d",
                                  tcp->pid, nprocs);
@@ -815,12 +819,16 @@ droptcb(struct tcb *tcp)
        free_tcb_priv_data(tcp);
 
 #ifdef ENABLE_STACKTRACE
-       if (stack_trace_enabled) {
+       if (stack_trace_enabled)
                unwind_tcb_fin(tcp);
-       }
 #endif
 
-       mmap_cache_delete(tcp, __func__);
+#ifdef HAVE_LINUX_KVM_H
+       kvm_vcpu_info_free(tcp);
+#endif
+
+       if (tcp->mmap_cache)
+               tcp->mmap_cache->free_fn(tcp, __func__);
 
        nprocs--;
        debug_msg("dropped tcb for pid %d, %d remain", tcp->pid, nprocs);
@@ -1597,7 +1605,7 @@ init(int argc, char *argv[])
 #ifdef ENABLE_STACKTRACE
            "k"
 #endif
-           "a:Ab:cCdDe:E:fFhiI:o:O:p:P:qrs:S:tTu:vVwxyz")) != EOF) {
+           "a:Ab:cCdDe:E:fFhiI:o:O:p:P:qrs:S:tTu:vVwxX:yz")) != EOF) {
                switch (c) {
                case 'a':
                        acolumn = string_to_uint(optarg);
@@ -1712,6 +1720,16 @@ init(int argc, char *argv[])
                case 'x':
                        xflag++;
                        break;
+               case 'X':
+                       if (!strcmp(optarg, "raw"))
+                               xlat_verbosity = XLAT_STYLE_RAW;
+                       else if (!strcmp(optarg, "abbrev"))
+                               xlat_verbosity = XLAT_STYLE_ABBREV;
+                       else if (!strcmp(optarg, "verbose"))
+                               xlat_verbosity = XLAT_STYLE_VERBOSE;
+                       else
+                               error_opt_arg(c, optarg);
+                       break;
                case 'y':
                        show_fd_path++;
                        break;
@@ -1777,16 +1795,8 @@ init(int argc, char *argv[])
        set_sighandler(SIGCHLD, SIG_DFL, &params_for_tracee.child_sa);
 
 #ifdef ENABLE_STACKTRACE
-       if (stack_trace_enabled) {
-               unsigned int tcbi;
-
+       if (stack_trace_enabled)
                unwind_init();
-               for (tcbi = 0; tcbi < tcbtabsize; ++tcbi) {
-                       if (!tcbtab[tcbi]->pid)
-                               continue;
-                       unwind_tcb_init(tcbtab[tcbi]);
-               }
-       }
 #endif
 
        /* See if they want to run as another user. */