aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/fish.cpp
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-05-15 19:45:02 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-05-17 14:52:55 -0700
commit73f2992a2e9ef1c96d45d9e90cc5e1f63a0afc92 (patch)
treecd32803426e1abf4910ecdbad333c2b19af46d2c /src/fish.cpp
parentd55113b5b5e242b1ccfd7d8c916c38b7092b0bd3 (diff)
make debug() output more useful
This change does several things. First, and most important, it allows dumping the "n" most recent stack frames on each debug() call. Second, it demangles the C++ symbols. Third, it prepends each debug() message with the debug level. Unrelated to the above I've replaced all `assert(!is_forked_child());` statements with `ASSERT_IS_NOT_FORKED_CHILD()` for consistency.
Diffstat (limited to 'src/fish.cpp')
-rw-r--r--src/fish.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/fish.cpp b/src/fish.cpp
index d8192c86..c4158dde 100644
--- a/src/fish.cpp
+++ b/src/fish.cpp
@@ -309,11 +309,12 @@ static int read_init(const struct config_paths_t &paths) {
return 1;
}
-/// Parse the argument list, return the index of the first non-switch arguments.
+/// Parse the argument list, return the index of the first non-flag arguments.
static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds) {
- const char *short_opts = "+hilnvc:p:d:";
+ const char *short_opts = "+hilnvc:p:d:D:";
const struct option long_opts[] = {{"command", required_argument, NULL, 'c'},
{"debug-level", required_argument, NULL, 'd'},
+ {"debug-stack-frames", required_argument, NULL, 'D'},
{"interactive", no_argument, NULL, 'i'},
{"login", no_argument, NULL, 'l'},
{"no-execute", no_argument, NULL, 'n'},
@@ -343,7 +344,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
if (tmp >= 0 && tmp <= 10 && !*end && !errno) {
debug_level = (int)tmp;
} else {
- fwprintf(stderr, _(L"Invalid value '%s' for debug level switch"), optarg);
+ fwprintf(stderr, _(L"Invalid value '%s' for debug-level flag"), optarg);
exit(1);
}
break;
@@ -373,6 +374,21 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
fwprintf(stdout, _(L"%s, version %s\n"), PACKAGE_NAME, get_fish_version());
exit(0);
}
+ case 'D': {
+ char *end;
+ long tmp;
+
+ errno = 0;
+ tmp = strtol(optarg, &end, 10);
+
+ if (tmp > 0 && tmp <= 128 && !*end && !errno) {
+ debug_stack_frames = (int)tmp;
+ } else {
+ fwprintf(stderr, _(L"Invalid value '%s' for debug-stack-frames flag"), optarg);
+ exit(1);
+ }
+ break;
+ }
default: {
// We assume getopt_long() has already emitted a diagnostic msg.
exit(1);