New switch '-l' which allows to debug the loading of the traced application.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11698 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <debugger.h>
|
#include <debugger.h>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include "MemoryReader.h"
|
#include "MemoryReader.h"
|
||||||
#include "Syscall.h"
|
#include "Syscall.h"
|
||||||
@@ -54,6 +55,8 @@ static const char *kUsage =
|
|||||||
" -c - Don't colorize output.\n"
|
" -c - Don't colorize output.\n"
|
||||||
" -f - Fast mode. Syscall arguments contents aren't retrieved.\n"
|
" -f - Fast mode. Syscall arguments contents aren't retrieved.\n"
|
||||||
" -h, --help - Print this text.\n"
|
" -h, --help - Print this text.\n"
|
||||||
|
" -l - Also trace loading the excecutable. Only considered when\n"
|
||||||
|
" an executable is provided.\n"
|
||||||
" -r - Don't print syscall return values.\n"
|
" -r - Don't print syscall return values.\n"
|
||||||
" -s - Also trace all threads spawned by the supplied thread,\n"
|
" -s - Also trace all threads spawned by the supplied thread,\n"
|
||||||
" respectively the loaded executable's main thread.\n"
|
" respectively the loaded executable's main thread.\n"
|
||||||
@@ -162,7 +165,7 @@ find_program(const char *programName, string &resolvedPath)
|
|||||||
|
|
||||||
// load_program
|
// load_program
|
||||||
thread_id
|
thread_id
|
||||||
load_program(const char *const *args, int32 argCount)
|
load_program(const char *const *args, int32 argCount, bool traceLoading)
|
||||||
{
|
{
|
||||||
// clone the argument vector so that we can change it
|
// clone the argument vector so that we can change it
|
||||||
const char **mutableArgs = new const char*[argCount];
|
const char **mutableArgs = new const char*[argCount];
|
||||||
@@ -176,8 +179,15 @@ load_program(const char *const *args, int32 argCount)
|
|||||||
return error;
|
return error;
|
||||||
mutableArgs[0] = programPath.c_str();
|
mutableArgs[0] = programPath.c_str();
|
||||||
|
|
||||||
|
// count environment variables
|
||||||
|
int envCount = 0;
|
||||||
|
while (environ[envCount] != NULL)
|
||||||
|
envCount++;
|
||||||
|
|
||||||
// load the program
|
// load the program
|
||||||
error = load_image(argCount, mutableArgs, (const char**)environ);
|
error = _kern_load_image(argCount, mutableArgs, envCount,
|
||||||
|
(const char**)environ, B_NORMAL_PRIORITY,
|
||||||
|
(traceLoading ? 0 : B_WAIT_TILL_LOADED));
|
||||||
|
|
||||||
delete[] mutableArgs;
|
delete[] mutableArgs;
|
||||||
|
|
||||||
@@ -375,6 +385,7 @@ main(int argc, const char *const *argv)
|
|||||||
bool printArguments = true;
|
bool printArguments = true;
|
||||||
bool colorize = true;
|
bool colorize = true;
|
||||||
bool fastMode = false;
|
bool fastMode = false;
|
||||||
|
bool traceLoading = false;
|
||||||
bool printReturnValues = true;
|
bool printReturnValues = true;
|
||||||
bool traceChildThreads = false;
|
bool traceChildThreads = false;
|
||||||
bool traceTeam = false;
|
bool traceTeam = false;
|
||||||
@@ -391,6 +402,8 @@ main(int argc, const char *const *argv)
|
|||||||
colorize = false;
|
colorize = false;
|
||||||
} else if (strcmp(arg, "-f") == 0) {
|
} else if (strcmp(arg, "-f") == 0) {
|
||||||
fastMode = true;
|
fastMode = true;
|
||||||
|
} else if (strcmp(arg, "-l") == 0) {
|
||||||
|
traceLoading = true;
|
||||||
} else if (strcmp(arg, "-r") == 0) {
|
} else if (strcmp(arg, "-r") == 0) {
|
||||||
printReturnValues = false;
|
printReturnValues = false;
|
||||||
} else if (strcmp(arg, "-s") == 0) {
|
} else if (strcmp(arg, "-s") == 0) {
|
||||||
@@ -423,7 +436,12 @@ main(int argc, const char *const *argv)
|
|||||||
if (programArgCount > 1
|
if (programArgCount > 1
|
||||||
|| !get_id(*programArgs, (traceTeam ? team : thread))) {
|
|| !get_id(*programArgs, (traceTeam ? team : thread))) {
|
||||||
// we've been given an executable and need to load it
|
// we've been given an executable and need to load it
|
||||||
thread = load_program(programArgs, programArgCount);
|
thread = load_program(programArgs, programArgCount, traceLoading);
|
||||||
|
if (thread < 0) {
|
||||||
|
fprintf(stderr, "Failed to start `%s': %s\n", programArgs[0],
|
||||||
|
strerror(thread));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the team ID, if we have none yet
|
// get the team ID, if we have none yet
|
||||||
|
|||||||
Reference in New Issue
Block a user