diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-07-19 14:09:58 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-11-18 10:43:14 -0500 |
commit | 063bea58bcc1c27864a0351bba07254855903377 (patch) | |
tree | 8a0f0ea303fbbc4b86d31c54dd9da761f658f4e2 /src/or | |
parent | f6d8bc9389db72dc654560d0f86fd3edd3b14934 (diff) | |
download | tor-063bea58bcc1c27864a0351bba07254855903377.tar.gz tor-063bea58bcc1c27864a0351bba07254855903377.zip |
Basic backtrace ability
On platforms with the backtrace/backtrace_symbols_fd interface, Tor
can now dump stack traces on assertion failure. By default, I log
them to DataDir/stack_dump and to stderr.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/config.c | 14 | ||||
-rw-r--r-- | src/or/main.c | 9 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/or/config.c b/src/or/config.c index ad6689ceef..af5bf41d24 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -12,6 +12,7 @@ #define CONFIG_PRIVATE #include "or.h" #include "addressmap.h" +#include "backtrace.h" #include "channel.h" #include "circuitbuild.h" #include "circuitlist.h" @@ -1113,6 +1114,19 @@ options_act_reversible(const or_options_t *old_options, char **msg) /* No need to roll back, since you can't change the value. */ } + /* Enable crash logging to files */ + { + /* XXXX we might want to set this up earlier, if possible! */ + char *backtrace_fname = NULL; + char *progname = NULL; + tor_asprintf(&backtrace_fname, "%s"PATH_SEPARATOR"stack_dump", + options->DataDirectory); + tor_asprintf(&progname, "Tor %s", get_version()); + configure_backtrace_handler(backtrace_fname, progname); + tor_free(backtrace_fname); + tor_free(progname); + } + /* Write control ports to disk as appropriate */ control_ports_write_to_file(); diff --git a/src/or/main.c b/src/or/main.c index d1728250a4..ea86df0738 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -12,6 +12,7 @@ #include "or.h" #include "addressmap.h" +#include "backtrace.h" #include "buffers.h" #include "channel.h" #include "channeltls.h" @@ -2304,7 +2305,7 @@ handle_signals(int is_parent) int tor_init(int argc, char *argv[]) { - char buf[256]; + char progname[256]; int i, quiet = 0; time_of_process_start = time(NULL); if (!connection_array) @@ -2314,8 +2315,8 @@ tor_init(int argc, char *argv[]) if (!active_linked_connection_lst) active_linked_connection_lst = smartlist_new(); /* Have the log set up with our application name. */ - tor_snprintf(buf, sizeof(buf), "Tor %s", get_version()); - log_set_application_name(buf); + tor_snprintf(progname, sizeof(progname), "Tor %s", get_version()); + log_set_application_name(progname); /* Initialize the history structures. */ rep_hist_init(); /* Initialize the service cache. */ @@ -2684,6 +2685,8 @@ tor_main(int argc, char *argv[]) } #endif + configure_backtrace_handler(NULL, get_version()); + update_approx_time(time(NULL)); tor_threads_init(); init_logging(); |