Changeset d4631b971e1f9590c6c91c0c266bfe665fccaaaf
- Timestamp:
- 06/21/10 09:04:19 (2 years ago)
- Author:
- Antti-Juhani Kaijanaho <ajk@…>
- Children:
- 72ebe081314754cf0300ebd5b8969fac31b3330e
- Parents:
- 959687afa28ccfe698945609bed89f4f17adc1cb
- git-committer:
- Antti-Juhani Kaijanaho <ajk@…> (06/21/10 09:04:19)
- Message:
-
Use gdb to get more readable assertion backtraces
Signed-off-by: Antti-Juhani Kaijanaho <ajk@…>
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r19beb87
|
rd4631b9
|
|
| 17 | 17 | @BOOST_PROGRAM_OPTIONS_LIB@ @BOOST_THREAD_LIB@ \ |
| 18 | 18 | @GnuTLS_LIBS@ |
| 19 | | DEFS = @DEFS@ -DCONFFILE=\"$(cfgfile)\" |
| | 19 | DEFS = @DEFS@ -DCONFFILE=\"$(cfgfile)\" -DBINDIR=\"${bindir}\" |
| 20 | 20 | |
| 21 | 21 | INSTALL = @INSTALL@ |
-
|
r476f073
|
rd4631b9
|
|
| 18 | 18 | */ |
| 19 | 19 | |
| | 20 | #include "config.hh" |
| 20 | 21 | #include "logger/logline.hh" |
| 21 | 22 | |
| 22 | 23 | #include <boost/assert.hpp> |
| 23 | 24 | #include <execinfo.h> |
| | 25 | #include <stdio.h> |
| 24 | 26 | |
| 25 | 27 | namespace boost |
| … |
… |
|
| 50 | 52 | { |
| 51 | 53 | ll.nl(); |
| 52 | | ll << "\t" << bt[i]; |
| | 54 | ll << "\t" << bt[i] << "\n"; |
| | 55 | std::string bta = bt[i]; |
| | 56 | int ob = bta.find('['); |
| | 57 | int cb = bta.rfind(']'); |
| | 58 | if (ob == std::string::npos || cb == std::string::npos) continue; |
| | 59 | bta = bta.substr(ob + 1, cb - ob - 1); |
| | 60 | std::string gdb = "gdb --batch --ex 'info line *"; |
| | 61 | gdb += bta; |
| | 62 | gdb += "' "; |
| | 63 | gdb += config["executable"].as<std::string>(); |
| | 64 | gdb += " </dev/null"; |
| | 65 | FILE *fp = ::popen(gdb.c_str(), "r"); |
| | 66 | if (fp != 0) |
| | 67 | { |
| | 68 | while (true) |
| | 69 | { |
| | 70 | char buf[128]; |
| | 71 | int n = ::fread(buf, 1, sizeof buf, fp); |
| | 72 | ll << std::string(buf, n); |
| | 73 | if (n == 0) break; |
| | 74 | } |
| | 75 | ::pclose(fp); |
| | 76 | } |
| 53 | 77 | } |
| 54 | 78 | ll.close(); |
-
|
r19beb87
|
rd4631b9
|
|
| 53 | 53 | opts.add_options() |
| 54 | 54 | ( "help", "show this help message") |
| | 55 | ( "executable", |
| | 56 | po::value<std::string>()->default_value(BINDIR "/alue"), |
| | 57 | "the location of a debuggable executable (for backtraces)" ) |
| 55 | 58 | ( "daemon", |
| 56 | 59 | po::value<bool>()->default_value(true), |