[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24026 - monkey/trunk/pathologist/src/pathologist
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24026 - monkey/trunk/pathologist/src/pathologist |
Date: |
Thu, 27 Sep 2012 03:19:35 +0200 |
Author: teichm
Date: 2012-09-27 03:19:35 +0200 (Thu, 27 Sep 2012)
New Revision: 24026
Modified:
monkey/trunk/pathologist/src/pathologist/pathologist.c
Log:
binary is no more a "-b" option.
reordered options.
Modified: monkey/trunk/pathologist/src/pathologist/pathologist.c
===================================================================
--- monkey/trunk/pathologist/src/pathologist/pathologist.c 2012-09-26
21:22:44 UTC (rev 24025)
+++ monkey/trunk/pathologist/src/pathologist/pathologist.c 2012-09-27
01:19:35 UTC (rev 24026)
@@ -35,6 +35,7 @@
static char *dumpFileName;
static char *binaryName;
+static char *command;
static char *binaryArgs;
static char *emailAddress;
static char *edbFilePath;
@@ -116,18 +117,12 @@
/* Check if the target program is and ELF binary */
if (MONKEY_NO == checkELF(binaryName)) {
FILE* targetProgramPipe;
- char *command = NULL;
char buffer[128];
ret = 1;
fprintf(stderr, "Target program is not an ELF. Pathologist will not
debug the program.\n");
fprintf(stderr, "Pathologist will attempt to run the program
normally.\n");
- if (NULL != binaryArgs) {
- MONKEY_asprintf(&command, "%s %s", binaryName, binaryArgs);
- } else {
- command = binaryName;
- }
targetProgramPipe = popen(command, "r");
if (NULL == targetProgramPipe) {
fprintf(stderr, "Target is not a binary.\n");
@@ -170,18 +165,6 @@
MONKEY_asprintf(&dumpFileName, "%s_PID%d", bn, getpid());
}
-// if (strcasecmp (mode, "email") == 0)
-// {
-// if (NULL == emailAddress)
-// {
-// fprintf( stderr,
-// "Working in email mode requires an email address!\n");
-// MONKEY_break (0);
-// ret = 1;
-// return;
-// }
-// }
-
/* Initialize context for the Action API */
cntxt = MONKEY_malloc (sizeof (struct MONKEY_ACTION_Context));
cntxt->email_address = emailAddress;
@@ -279,8 +262,12 @@
{
if (NULL != dumpFileName)
MONKEY_free(dumpFileName);
- if (NULL != binaryName)
- MONKEY_free(binaryName);
+// if (NULL != binaryName)
+// MONKEY_free(binaryName);
+// if (NULL != binaryArgs)
+// MONKEY_free(binaryArgs);
+// if (NULL != command)
+// MONKEY_free(command);
if (NULL != emailAddress)
MONKEY_free(emailAddress);
if (NULL != edbFilePath)
@@ -298,18 +285,7 @@
}
-void checkRequiredArgs()
-{
- if (NULL == binaryName)
- printf("Error: missing argument: path to the binary file.\n");
- if (NULL == edbFilePath)
- printf("Error: missing argument: path to expression database
file.\n");
- if (NULL == binaryName || NULL == edbFilePath) {
- exit(EXIT_FAILURE);
- }
-}
-
const char * buildBinaryArgs(int argc, char **argv) {
char * res = MONKEY_strdup("");
char * tmp;
@@ -327,14 +303,18 @@
main (int argc, char *argv[])
{
static const struct MONKEY_GETOPT_CommandLineOption options[] = {
- {'b', "binary", "FILENAME", "the binary to debug",
- 1, &MONKEY_GETOPT_set_string, &binaryName},
{'d', "database", "FILENAME", "the expression database to use,
generated by seaspider",
1, &MONKEY_GETOPT_set_string, &edbFilePath},
{'f', "function", "FUNCTIONNAME", "the name of the function, in
which pathologist will set a breakpoint",
1, &MONKEY_GETOPT_set_string, &inspectFunction},
+ {'g', "gdb", "FILENAME", "path to gdb binary to use. If not
passed, pathologist will set it to /usr/bin/gdb",
+ 1, &MONKEY_GETOPT_set_string, &gdbBinaryPath},
+ {'h', "help", NULL, "shows this help",
+ 0, &MONKEY_GETOPT_format_help_, "Monkey Pathologist:
Automatically debug a service"},
{'i', "inspect", "EXPRESSIONNAME", "expression to inspect in
the function specified after argument f",
1, &MONKEY_GETOPT_set_string, &inspectExpression},
+ {'l', "valgrind", "FILENAME", "path to valgrind binary. If not
passed, pathologist will set it to /usr/bin/valgrind",
+ 1, &MONKEY_GETOPT_set_string, &valgrindBinaryPath},
{'m', "mail", "MAILADDRESS", "if specified, pathologist will
send the bugreport to the given address",
1, &MONKEY_GETOPT_set_string, &emailAddress},
{'o', "report", "FILENAME", "saves the xml formated report to
the given file",
@@ -343,26 +323,29 @@
1, &MONKEY_GETOPT_set_uint, &scopeDepth},
{'r', "reverse", NULL, "enables reverse execution",
0, &MONKEY_GETOPT_set_one, &reverseExecutionAllowed},
- {'g', "gdb", "FILENAME", "path to gdb binary to use. If not
passed, pathologist will set it to /usr/bin/gdb",
- 1, &MONKEY_GETOPT_set_string, &gdbBinaryPath},
- {'l', "valgrind", "FILENAME", "path to valgrind binary. If not
passed, pathologist will set it to /usr/bin/valgrind",
- 1, &MONKEY_GETOPT_set_string, &valgrindBinaryPath},
- {'h', "help", NULL, "shows this help",
- 0, &MONKEY_GETOPT_format_help_, "Monkey Pathologist:
Automatically debug a service"},
{'v', "version", NULL, "print the version number",
0, &MONKEY_GETOPT_print_version_, "0.1 alpha"},
MONKEY_GETOPT_OPTION_END
};
- if (-1 == (ret = MONKEY_GETOPT_run ("pathologist", options, (unsigned
int) argc, argv)))
+ if (-1 == (ret = MONKEY_GETOPT_run ("pathologist -d DATABASEFILE
[options] [--] BINARY", options, (unsigned int) argc, argv)))
return -1;
-
- checkRequiredArgs();
+ // Check for required arguments
+ if (argc <= ret)
+ printf("Error: missing argument: path to the binary file.\n");
+ if (NULL == edbFilePath)
+ printf("Error: missing argument: path to expression database
file.\n");
+ if (argc <= ret || NULL == edbFilePath)
+ exit(EXIT_FAILURE);
/* All remaining args are considered program arguments */
- binaryArgs = (char *)buildBinaryArgs(argc - ret, &argv[ret]);
+ binaryName = argv[ret];
+ command = (char *)buildBinaryArgs(argc - ret, &argv[ret]) + 1;
+ binaryArgs = (char *)buildBinaryArgs(argc - ret - 1, &argv[ret + 1]);
+ printf("\n%s\n%s\n%s\n\n", binaryName, command, binaryArgs);
+
/* Run Pathologist */
run();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24026 - monkey/trunk/pathologist/src/pathologist,
gnunet <=