]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Reinstate printing of log-file-qualifiers in XML output (Ashley Pittman).
authorJulian Seward <jseward@acm.org>
Wed, 4 Jun 2008 06:51:58 +0000 (06:51 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 4 Jun 2008 06:51:58 +0000 (06:51 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8178

coregrind/m_main.c
docs/internals/xml-output.txt

index 551349f4159eb0fe21e1993134db3a826d3fae40..771747096599f062266e67d2041663ddf9a7cf15 100644 (file)
@@ -719,6 +719,47 @@ static Bool main_process_cmd_line_options( UInt* client_auxv,
    return (log_to == VgLogTo_Fd);
 }
 
+// Write the name and value of log file qualifiers to the xml file.
+static void print_file_vars(Char* format)
+{
+   Int i = 0;
+   
+   while (format[i]) {
+      if (format[i] == '%') {
+         // We saw a '%'.  What's next...
+         i++;
+        if ('q' == format[i]) {
+            i++;
+            if ('{' == format[i]) {
+              // Get the env var name, print its contents.
+              Char* qualname;
+               Char* qual;
+               i++;
+               qualname = &format[i];
+               while (True) {
+                 if ('}' == format[i]) {
+                     // Temporarily replace the '}' with NUL to extract var
+                     // name.
+                    format[i] = 0;
+                     qual = VG_(getenv)(qualname);
+                    break;
+                  }
+                  i++;
+               }
+
+              VG_(message)(Vg_UserMsg, "<logfilequalifier> <var>%t</var> "
+                           "<value>%t</value> </logfilequalifier>",
+                           qualname,qual);
+              format[i] = '}';
+              i++;
+           }
+         }
+      } else {
+        i++;
+      }
+   }
+}
+
 
 /*====================================================================*/
 /*=== Printing the preamble                                        ===*/
@@ -813,16 +854,7 @@ static void print_preamble(Bool logging_to_fd, const char* toolname)
       VG_(message)(Vg_UserMsg, "<pid>%d</pid>", VG_(getpid)());
       VG_(message)(Vg_UserMsg, "<ppid>%d</ppid>", VG_(getppid)());
       VG_(message)(Vg_UserMsg, "<tool>%t</tool>", toolname);
-// [This was made obsolete by the --log-file change in 3.3.0.  But
-// I'm leaving it here (commented out) in case it needs to be reinstated in
-// some way --njn]
-//      if (VG_(clo_log_file_qualifier)) {
-//         HChar* val = VG_(getenv)(VG_(clo_log_file_qualifier));
-//         VG_(message)(Vg_UserMsg, "<logfilequalifier> <var>%t</var> "
-//                                  "<value>%t</value> </logfilequalifier>",
-//                                  VG_(clo_log_file_qualifier),
-//                                  val ? val : "");
-//      }
+      print_file_vars(VG_(clo_log_name));
       if (VG_(clo_xml_user_comment)) {
          /* Note: the user comment itself is XML and is therefore to
             be passed through verbatim (%s) rather than escaped
index 2ad21c323757d006de5218c9b3ffe6ca61caa364..c232aacda790f70f5be2a1c48a02dc18b99a455e 100644 (file)
@@ -115,8 +115,7 @@ PROTOCOL for version 3
 ----------------------
 Changes in 3.4.X (tentative): (jrs, 1 March 2008)
 
-* There may be more than one <logfilequalifier> clause, depending on
-  how this pans out.  (AshleyP perhaps to investigate)
+* There may be more than one <logfilequalifier> clause.
 
 * Some errors may have two <auxwhat> blocks, rather than just one
   (resulting from merge of the DATASYMS branch)