diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-08-22 20:34:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-08-22 20:34:56 +0900 |
commit | 517f5529d7008eba87b8b2fee5ec9ec0a5075f6e (patch) | |
tree | c71720a9b41309713c089478f921165bd2d63b25 /libltrace.c | |
parent | 689b9dbb8d7f88ab91e7741932ed000b6e49be9a (diff) | |
download | ltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.tar.gz ltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.tar.bz2 ltrace-517f5529d7008eba87b8b2fee5ec9ec0a5075f6e.zip |
Imported Upstream version 0.7.91upstream/0.7.91upstream
Diffstat (limited to 'libltrace.c')
-rw-r--r-- | libltrace.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/libltrace.c b/libltrace.c index 559edfa..d43a9b2 100644 --- a/libltrace.c +++ b/libltrace.c @@ -1,6 +1,6 @@ /* * This file is part of ltrace. - * Copyright (C) 2011,2012 Petr Machata, Red Hat Inc. + * Copyright (C) 2011,2012,2013 Petr Machata, Red Hat Inc. * Copyright (C) 2009 Juan Cespedes * * This program is free software; you can redistribute it and/or @@ -21,6 +21,7 @@ #include "config.h" +#include <limits.h> #include <sys/param.h> #include <sys/wait.h> #include <errno.h> @@ -34,19 +35,20 @@ #include "proc.h" #include "read_config_file.h" #include "backend.h" +#include "prototype.h" char *command = NULL; int exiting = 0; /* =1 if a SIGINT or SIGTERM has been received */ static enum callback_status -stop_non_p_processes(Process *proc, void *data) +stop_non_p_processes(struct process *proc, void *data) { int stop = 1; struct opt_p_t *it; for (it = opt_p; it != NULL; it = it->next) { - Process * p_proc = pid2proc(it->pid); + struct process *p_proc = pid2proc(it->pid); if (p_proc == NULL) { printf("stop_non_p_processes: %d terminated?\n", it->pid); continue; @@ -88,9 +90,8 @@ signal_exit(int sig) static void normal_exit(void) { - if (options.summary) { + if (options.summary) show_summary(); - } if (options.output) { fclose(options.output); options.output = NULL; @@ -107,41 +108,16 @@ ltrace_init(int argc, char **argv) { argv = process_options(argc, argv); init_global_config(); - while (opt_F) { - /* If filename begins with ~, expand it to the user's home */ - /* directory. This does not correctly handle ~yoda, but that */ - /* isn't as bad as it seems because the shell will normally */ - /* be doing the expansion for us; only the hardcoded */ - /* ~/.ltrace.conf should ever use this code. */ - if (opt_F->filename[0] == '~') { - char path[PATH_MAX]; - char *home_dir = getenv("HOME"); - if (home_dir) { - strncpy(path, home_dir, PATH_MAX - 1); - path[PATH_MAX - 1] = '\0'; - strncat(path, opt_F->filename + 1, - PATH_MAX - strlen(path) - 1); - read_config_file(path); - } - } else { - read_config_file(opt_F->filename); - } - struct opt_F_t *next = opt_F->next; - if (opt_F->own_filename) - free(opt_F->filename); - free(opt_F); - opt_F = next; - } if (command) { /* Check that the binary ABI is supported before * calling execute_program. */ - struct ltelf lte = {}; - open_elf(<e, command); - do_close_elf(<e); + struct ltelf lte; + ltelf_init(<e, command); + ltelf_destroy(<e); pid_t pid = execute_program(command, argv); - struct Process *proc = open_program(command, pid); + struct process *proc = open_program(command, pid); if (proc == NULL) { fprintf(stderr, "couldn't open program '%s': %s\n", command, strerror(errno)); |