]> git.cworth.org Git - apitrace/blobdiff - common/trace_tools_trace.cpp
More helpful messages on exceptions inside apitrace code.
[apitrace] / common / trace_tools_trace.cpp
index d1d64833f61bff5e635fe45d46d22b23888d12a6..768fd108d3541eaf1352b09c910b2c4c335bd1ea 100644 (file)
@@ -30,7 +30,9 @@
 
 #include <iostream>
 
-#include "os_path.hpp"
+#include "os_string.hpp"
+#include "os_process.hpp"
+#include "trace_resource.hpp"
 #include "trace_tools.hpp"
 
 
@@ -51,39 +53,6 @@ namespace trace {
 #endif
 
 
-os::Path
-findFile(const char *relPath,
-         const char *absPath,
-         bool verbose)
-{
-    os::Path complete;
-
-    /* First look in the same directory from which this process is
-     * running, (to support developers running a compiled program that
-     * has not been installed. */
-    os::Path process_dir = os::getProcessName();
-
-    process_dir.trimFilename();
-
-    complete = process_dir;
-    complete.join(relPath);
-
-    if (complete.exists())
-        return complete;
-
-    /* Second, look in the directory for installed wrappers. */
-    complete = absPath;
-    if (complete.exists())
-        return complete;
-
-    if (verbose) {
-        std::cerr << "error: cannot find " << relPath << " or " << absPath << "\n";
-    }
-
-    return "";
-}
-
-
 int
 traceProgram(API api,
              char * const *argv,
@@ -112,7 +81,7 @@ traceProgram(API api,
         return 1;
     }
 
-    os::Path wrapper;
+    os::String wrapper;
     wrapper = findFile(relPath, absPath, verbose);
 
     if (!wrapper.length()) {
@@ -127,6 +96,8 @@ traceProgram(API api,
         APITRACE_WRAPPER_INSTALL_DIR "\n"
         "to the directory with the application to trace, then run the application.\n";
 
+    return 1;
+
 #else
 
 #if defined(__APPLE__)
@@ -155,17 +126,16 @@ traceProgram(API api,
         std::cerr << "\n";
     }
 
-    execvp(argv[0], argv);
+    int status = os::execute(argv);
 
     unsetenv(TRACE_VARIABLE);
     if (output) {
         unsetenv("TRACE_FILE");
     }
-
-    std::cerr << "error: Failed to execute " << argv[0] << "\n";
+    
+    return status;
 #endif
 
-    return 1;
 }