Skip to content

Commit

Permalink
Print die info into stdcerr
Browse files Browse the repository at this point in the history
  • Loading branch information
mimicji committed Aug 28, 2020
1 parent 37a4f09 commit 82e20f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion libpeekaboo/libpeekaboo.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define MAX_PATH (256)
#define LIBPEEKABOO_VER 2

#define PEEKABOO_DIE(...) {printf(__VA_ARGS__); exit(1);}
#define PEEKABOO_DIE(...) {fprintf(stderr, __VA_ARGS__); exit(1);}

// Bunch of type definitions for register sizes
typedef union {
Expand Down
14 changes: 2 additions & 12 deletions peekaboo_dr/peekaboo_dr.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,7 @@ static void event_thread_init(void *drcontext)

char dir_path[256], name[256];
snprintf(name, 256, "%s-%d", dr_get_application_name(), root_pid);
if (create_folder(name, dir_path, 256))
{
fprintf(stderr, "Peekaboo: Unable to create directory %s.\n", name);
exit(1);
}

if (create_folder(name, dir_path, 256)) PEEKABOO_DIE("Peekaboo: Unable to create directory %s.\n", name);

dr_mutex_lock(mutex);
create_trace_file(dir_path, "insn.bytemap", 256, &bytes_map_file);
Expand All @@ -433,7 +428,6 @@ static void event_thread_init(void *drcontext)
chmod(name, S_IRWXU|S_IRWXG|S_IRWXO);
dr_mutex_unlock(mutex);


printf("Peekaboo: Main thread starts. ");
init_thread_in_process(drcontext);
}
Expand All @@ -446,11 +440,7 @@ static void fork_init(void *drcontext)
FILE * fp;
dr_mutex_lock(mutex);
fp = fopen(name, "a");
if (fp == NULL)
{
fprintf(stderr, "Peekaboo: Cannot append to process tree!");
exit(1);
}
if (fp == NULL) PEEKABOO_DIE("Peekaboo: Cannot append to process tree!");
fprintf(fp, "%d-%d\n", dr_get_parent_id(), dr_get_process_id());
fclose(fp);
dr_mutex_unlock(mutex);
Expand Down

0 comments on commit 82e20f6

Please sign in to comment.