Convert debug(0) calls to FLOG

This commit is contained in:
ridiculousfish 2019-05-27 15:56:53 -07:00
parent 6282ac5713
commit ea9d1ad82f
21 changed files with 95 additions and 79 deletions

View file

@ -66,6 +66,7 @@
#include "complete.h" #include "complete.h"
#include "exec.h" #include "exec.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "flog.h"
#include "intern.h" #include "intern.h"
#include "io.h" #include "io.h"
#include "parse_constants.h" #include "parse_constants.h"
@ -469,7 +470,7 @@ proc_status_t builtin_run(parser_t &parser, int job_pgid, wchar_t **argv, io_str
return proc_status_t::from_exit_code(ret); return proc_status_t::from_exit_code(ret);
} }
debug(0, UNKNOWN_BUILTIN_ERR_MSG, argv[0]); FLOGF(error, UNKNOWN_BUILTIN_ERR_MSG, argv[0]);
return proc_status_t::from_exit_code(STATUS_CMD_ERROR); return proc_status_t::from_exit_code(STATUS_CMD_ERROR);
} }

View file

@ -52,6 +52,7 @@
#include "env.h" #include "env.h"
#include "expand.h" #include "expand.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "flog.h"
#include "future_feature_flags.h" #include "future_feature_flags.h"
#include "global_safety.h" #include "global_safety.h"
#include "proc.h" #include "proc.h"
@ -2121,8 +2122,8 @@ int create_directory(const wcstring &d) {
} }
[[gnu::noinline]] void bugreport() { [[gnu::noinline]] void bugreport() {
debug(0, _(L"This is a bug. Break on 'bugreport' to debug.")); FLOG(error, _(L"This is a bug. Break on 'bugreport' to debug."));
debug(0, _(L"If you can reproduce it, please report: %s."), PACKAGE_BUGREPORT); FLOG(error, _(L"If you can reproduce it, please report: "), PACKAGE_BUGREPORT, '.');
} }
wcstring format_size(long long sz) { wcstring format_size(long long sz) {
@ -2314,24 +2315,24 @@ bool is_main_thread() {
void assert_is_main_thread(const char *who) { void assert_is_main_thread(const char *who) {
if (!is_main_thread() && !thread_asserts_cfg_for_testing) { if (!is_main_thread() && !thread_asserts_cfg_for_testing) {
debug(0, "%s called off of main thread.", who); FLOGF(error, "%s called off of main thread.", who);
debug(0, "Break on debug_thread_error to debug."); FLOGF(error, "Break on debug_thread_error to debug.");
debug_thread_error(); debug_thread_error();
} }
} }
void assert_is_not_forked_child(const char *who) { void assert_is_not_forked_child(const char *who) {
if (is_forked_child()) { if (is_forked_child()) {
debug(0, "%s called in a forked child.", who); FLOGF(error, "%s called in a forked child.", who);
debug(0, "Break on debug_thread_error to debug."); FLOGF(error, "Break on debug_thread_error to debug.");
debug_thread_error(); debug_thread_error();
} }
} }
void assert_is_background_thread(const char *who) { void assert_is_background_thread(const char *who) {
if (is_main_thread() && !thread_asserts_cfg_for_testing) { if (is_main_thread() && !thread_asserts_cfg_for_testing) {
debug(0, "%s called on the main thread (may block!).", who); FLOGF(error, "%s called on the main thread (may block!).", who);
debug(0, "Break on debug_thread_error to debug."); FLOGF(error, "Break on debug_thread_error to debug.");
debug_thread_error(); debug_thread_error();
} }
} }
@ -2342,8 +2343,8 @@ void assert_is_locked(void *vmutex, const char *who, const char *caller) {
// Note that std::mutex.try_lock() is allowed to return false when the mutex isn't // Note that std::mutex.try_lock() is allowed to return false when the mutex isn't
// actually locked; fortunately we are checking the opposite so we're safe. // actually locked; fortunately we are checking the opposite so we're safe.
if (mutex->try_lock()) { if (mutex->try_lock()) {
debug(0, "%s is not locked when it should be in '%s'", who, caller); FLOGF(error, "%s is not locked when it should be in '%s'", who, caller);
debug(0, "Break on debug_thread_error to debug."); FLOGF(error, "Break on debug_thread_error to debug.");
debug_thread_error(); debug_thread_error();
mutex->unlock(); mutex->unlock();
} }
@ -2436,10 +2437,10 @@ void redirect_tty_output() {
/// Display a failed assertion message, dump a stack trace if possible, then die. /// Display a failed assertion message, dump a stack trace if possible, then die.
[[noreturn]] void __fish_assert(const char *msg, const char *file, size_t line, int error) { [[noreturn]] void __fish_assert(const char *msg, const char *file, size_t line, int error) {
if (error) { if (error) {
debug(0, L"%s:%zu: failed assertion: %s: errno %d (%s)", file, line, msg, error, FLOG(error, L"%s:%zu: failed assertion: %s: errno %d (%s)", file, line, msg, error,
std::strerror(error)); std::strerror(error));
} else { } else {
debug(0, L"%s:%zu: failed assertion: %s", file, line, msg); FLOG(error, L"%s:%zu: failed assertion: %s", file, line, msg);
} }
show_stackframe(L'E', 99, 1); show_stackframe(L'E', 99, 1);
abort(); abort();

View file

@ -904,7 +904,7 @@ bool completer_t::complete_param(const wcstring &cmd_orig, const wcstring &popt,
} }
}; };
// debug(0, L"\nThinking about looking up completions for %ls\n", cmd.c_str()); // FLOG(error, L"\nThinking about looking up completions for %ls\n", cmd.c_str());
bool head_exists = builtin_exists(cmd); bool head_exists = builtin_exists(cmd);
// Only reload environment variables if builtin_exists returned false, as an optimization // Only reload environment variables if builtin_exists returned false, as an optimization
if (head_exists == false) { if (head_exists == false) {

View file

@ -24,6 +24,7 @@
#include "event.h" #include "event.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "fish_version.h" #include "fish_version.h"
#include "flog.h"
#include "global_safety.h" #include "global_safety.h"
#include "history.h" #include "history.h"
#include "input.h" #include "input.h"
@ -139,7 +140,7 @@ void fix_colon_delimited_var(const wcstring &var_name, env_stack_t &vars) {
std::replace(newstrs.begin(), newstrs.end(), empty, wcstring(L".")); std::replace(newstrs.begin(), newstrs.end(), empty, wcstring(L"."));
int retval = vars.set(var_name, ENV_DEFAULT | ENV_USER, std::move(newstrs)); int retval = vars.set(var_name, ENV_DEFAULT | ENV_USER, std::move(newstrs));
if (retval != ENV_OK) { if (retval != ENV_OK) {
debug(0, L"fix_colon_delimited_var failed unexpectedly with retval %d", retval); FLOG(error, L"fix_colon_delimited_var failed unexpectedly with retval %d", retval);
} }
} }
} }
@ -1351,8 +1352,8 @@ wcstring env_get_runtime_path() {
} }
if (!uname || check_runtime_path(tmpdir.c_str()) != 0) { if (!uname || check_runtime_path(tmpdir.c_str()) != 0) {
debug(0, L"Runtime path not available."); FLOG(error, L"Runtime path not available.");
debug(0, L"Try deleting the directory %s and restarting fish.", tmpdir.c_str()); FLOG(error, L"Try deleting the directory %s and restarting fish.", tmpdir.c_str());
return result; return result;
} }

View file

@ -40,6 +40,7 @@
#include "env.h" #include "env.h"
#include "env_universal_common.h" #include "env_universal_common.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "flog.h"
#include "path.h" #include "path.h"
#include "utf8.h" #include "utf8.h"
#include "util.h" // IWYU pragma: keep #include "util.h" // IWYU pragma: keep
@ -195,11 +196,11 @@ static bool append_file_entry(env_var_t::env_var_flags_t flags, const wcstring &
// Append variable name like "fish_color_cwd". // Append variable name like "fish_color_cwd".
if (!valid_var_name(key_in)) { if (!valid_var_name(key_in)) {
debug(0, L"Illegal variable name: '%ls'", key_in.c_str()); FLOG(error, L"Illegal variable name: '%ls'", key_in.c_str());
success = false; success = false;
} }
if (success && !append_utf8(key_in, result, storage)) { if (success && !append_utf8(key_in, result, storage)) {
debug(0, L"Could not convert %ls to narrow character string", key_in.c_str()); FLOG(error, L"Could not convert %ls to narrow character string", key_in.c_str());
success = false; success = false;
} }
@ -210,7 +211,7 @@ static bool append_file_entry(env_var_t::env_var_flags_t flags, const wcstring &
// Append value. // Append value.
if (success && !append_utf8(full_escape(val_in), result, storage)) { if (success && !append_utf8(full_escape(val_in), result, storage)) {
debug(0, L"Could not convert %ls to narrow character string", val_in.c_str()); FLOG(error, L"Could not convert %ls to narrow character string", val_in.c_str());
success = false; success = false;
} }
@ -447,7 +448,8 @@ bool env_universal_t::write_to_fd(int fd, const wcstring &path) {
std::string contents = serialize_with_vars(vars); std::string contents = serialize_with_vars(vars);
if (write_loop(fd, contents.data(), contents.size()) < 0) { if (write_loop(fd, contents.data(), contents.size()) < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
debug(0, _(L"Unable to write to universal variables file '%ls': %s"), path.c_str(), error); FLOG(error, _(L"Unable to write to universal variables file '%ls': %s"), path.c_str(),
error);
success = false; success = false;
} }
@ -462,7 +464,7 @@ bool env_universal_t::move_new_vars_file_into_place(const wcstring &src, const w
int ret = wrename(src, dst); int ret = wrename(src, dst);
if (ret != 0) { if (ret != 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
debug(0, _(L"Unable to rename file from '%ls' to '%ls': %s"), src.c_str(), dst.c_str(), FLOG(error, _(L"Unable to rename file from '%ls' to '%ls': %s"), src.c_str(), dst.c_str(),
error); error);
} }
return ret == 0; return ret == 0;
@ -525,7 +527,7 @@ bool env_universal_t::open_temporary_file(const wcstring &directory, wcstring *o
if (!success) { if (!success) {
const char *error = std::strerror(saved_errno); const char *error = std::strerror(saved_errno);
debug(0, _(L"Unable to open temporary file '%ls': %s"), out_path->c_str(), error); FLOG(error, _(L"Unable to open temporary file '%ls': %s"), out_path->c_str(), error);
} }
return success; return success;
} }
@ -587,7 +589,8 @@ bool env_universal_t::open_and_acquire_lock(const wcstring &path, int *out_fd) {
} }
#endif #endif
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
debug(0, _(L"Unable to open universal variable file '%ls': %s"), path.c_str(), error); FLOG(error, _(L"Unable to open universal variable file '%ls': %s"), path.c_str(),
error);
break; break;
} }
@ -1058,7 +1061,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
int fd = shm_open(path, O_RDWR | O_CREAT, 0600); int fd = shm_open(path, O_RDWR | O_CREAT, 0600);
if (fd < 0) { if (fd < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
debug(0, _(L"Unable to open shared memory with path '%s': %s"), path, error); FLOG(error, _(L"Unable to open shared memory with path '%s': %s"), path, error);
errored = true; errored = true;
} }
@ -1068,7 +1071,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
struct stat buf = {}; struct stat buf = {};
if (fstat(fd, &buf) < 0) { if (fstat(fd, &buf) < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
debug(0, _(L"Unable to fstat shared memory object with path '%s': %s"), path, FLOG(error, _(L"Unable to fstat shared memory object with path '%s': %s"), path,
error); error);
errored = true; errored = true;
} }
@ -1079,7 +1082,8 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
bool set_size = !errored && size < (off_t)sizeof(universal_notifier_shmem_t); bool set_size = !errored && size < (off_t)sizeof(universal_notifier_shmem_t);
if (set_size && ftruncate(fd, sizeof(universal_notifier_shmem_t)) < 0) { if (set_size && ftruncate(fd, sizeof(universal_notifier_shmem_t)) < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
debug(0, _(L"Unable to truncate shared memory object with path '%s': %s"), path, error); FLOG(error, _(L"Unable to truncate shared memory object with path '%s': %s"), path,
error);
errored = true; errored = true;
} }
@ -1089,8 +1093,8 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
MAP_SHARED, fd, 0); MAP_SHARED, fd, 0);
if (addr == MAP_FAILED) { if (addr == MAP_FAILED) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
debug(0, _(L"Unable to memory map shared memory object with path '%s': %s"), path, FLOG(error, _(L"Unable to memory map shared memory object with path '%s': %s"),
error); path, error);
this->region = NULL; this->region = NULL;
} else { } else {
this->region = static_cast<universal_notifier_shmem_t *>(addr); this->region = static_cast<universal_notifier_shmem_t *>(addr);
@ -1495,7 +1499,7 @@ void universal_notifier_named_pipe_t::make_pipe(const wchar_t *test_path) {
if (mkfifo_status == -1 && errno != EEXIST) { if (mkfifo_status == -1 && errno != EEXIST) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
const wchar_t *errmsg = _(L"Unable to make a pipe for universal variables using '%ls': %s"); const wchar_t *errmsg = _(L"Unable to make a pipe for universal variables using '%ls': %s");
debug(0, errmsg, vars_path.c_str(), error); FLOG(error, errmsg, vars_path.c_str(), error);
pipe_fd = -1; pipe_fd = -1;
return; return;
} }
@ -1504,7 +1508,7 @@ void universal_notifier_named_pipe_t::make_pipe(const wchar_t *test_path) {
if (fd < 0) { if (fd < 0) {
const char *error = std::strerror(errno); const char *error = std::strerror(errno);
const wchar_t *errmsg = _(L"Unable to open a pipe for universal variables using '%ls': %s"); const wchar_t *errmsg = _(L"Unable to open a pipe for universal variables using '%ls': %s");
debug(0, errmsg, vars_path.c_str(), error); FLOG(error, errmsg, vars_path.c_str(), error);
pipe_fd = -1; pipe_fd = -1;
return; return;
} }

View file

@ -62,7 +62,7 @@ void exec_close(int fd) {
// This may be called in a child of fork(), so don't allocate memory. // This may be called in a child of fork(), so don't allocate memory.
if (fd < 0) { if (fd < 0) {
debug(0, L"Called close on invalid file descriptor "); FLOG(error, L"Called close on invalid file descriptor ");
return; return;
} }
@ -614,20 +614,20 @@ static bool handle_builtin_output(parser_t &parser, const std::shared_ptr<job_t>
if (write_loop(STDOUT_FILENO, outbuff.data(), outbuff.size()) < 0) { if (write_loop(STDOUT_FILENO, outbuff.data(), outbuff.size()) < 0) {
if (errno != EPIPE) { if (errno != EPIPE) {
did_err = true; did_err = true;
debug(0, "Error while writing to stdout"); FLOG(error, "Error while writing to stdout");
wperror(L"write_loop"); wperror(L"write_loop");
} }
} }
if (write_loop(STDERR_FILENO, errbuff.data(), errbuff.size()) < 0) { if (write_loop(STDERR_FILENO, errbuff.data(), errbuff.size()) < 0) {
if (errno != EPIPE && !did_err) { if (errno != EPIPE && !did_err) {
did_err = true; did_err = true;
debug(0, "Error while writing to stderr"); FLOG(error, "Error while writing to stderr");
wperror(L"write_loop"); wperror(L"write_loop");
} }
} }
if (did_err) { if (did_err) {
redirect_tty_output(); // workaround glibc bug redirect_tty_output(); // workaround glibc bug
debug(0, "!builtin_io_done and errno != EPIPE"); FLOG(error, "!builtin_io_done and errno != EPIPE");
show_stackframe(L'E'); show_stackframe(L'E');
} }
// Clear the buffers to indicate we finished. // Clear the buffers to indicate we finished.
@ -789,7 +789,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr<job_t>
const wcstring func_name = p->argv0(); const wcstring func_name = p->argv0();
auto props = function_get_properties(func_name); auto props = function_get_properties(func_name);
if (!props) { if (!props) {
debug(0, _(L"Unknown function '%ls'"), p->argv0()); FLOG(error, _(L"Unknown function '%ls'"), p->argv0());
return false; return false;
} }

View file

@ -222,7 +222,7 @@ static size_t parse_slice(const wchar_t *in, wchar_t **end_ptr, std::vector<long
} }
// debug( 0, L"Push range idx %d %d", i1, i2 ); // debug( 0, L"Push range idx %d %d", i1, i2 );
for (long jjj = i1; jjj * direction <= i2 * direction; jjj += direction) { for (long jjj = i1; jjj * direction <= i2 * direction; jjj += direction) {
// debug(0, L"Expand range [subst]: %i\n", jjj); // FLOG(error, L"Expand range [subst]: %i\n", jjj);
idx.push_back(jjj); idx.push_back(jjj);
} }
continue; continue;

View file

@ -1237,7 +1237,7 @@ bool history_t::rewrite_to_temporary_file(int existing_fd, int dst_fd) const {
const history_item_t old_item = decode_item(*local_file, offset); const history_item_t old_item = decode_item(*local_file, offset);
if (old_item.empty() || deleted_items.count(old_item.str()) > 0) { if (old_item.empty() || deleted_items.count(old_item.str()) > 0) {
// debug(0, L"Item is deleted : %s\n", old_item.str().c_str()); // FLOG(error, L"Item is deleted : %s\n", old_item.str().c_str());
continue; continue;
} }
// Add this old item. // Add this old item.

View file

@ -15,6 +15,7 @@
#include <queue> #include <queue>
#include "common.h" #include "common.h"
#include "flog.h"
#include "global_safety.h" #include "global_safety.h"
#include "iothread.h" #include "iothread.h"
#include "wutil.h" #include "wutil.h"
@ -201,7 +202,7 @@ void iothread_service_completion() {
} else if (wakeup_byte == IO_SERVICE_RESULT_QUEUE) { } else if (wakeup_byte == IO_SERVICE_RESULT_QUEUE) {
iothread_service_result_queue(); iothread_service_result_queue();
} else { } else {
debug(0, "Unknown wakeup byte %02x in %s", wakeup_byte, __FUNCTION__); FLOG(error, "Unknown wakeup byte %02x in %s", wakeup_byte, __FUNCTION__);
} }
} }

View file

@ -27,6 +27,7 @@
#include "common.h" #include "common.h"
#include "env.h" #include "env.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "flog.h"
#include "output.h" #include "output.h"
#include "wutil.h" // IWYU pragma: keep #include "wutil.h" // IWYU pragma: keep
@ -528,7 +529,7 @@ void writembs_check(outputter_t &outp, const char *mbs, const char *mbs_name, bo
const wchar_t *fmt = const wchar_t *fmt =
_(L"Tried to use terminfo string %s on line %ld of %s, which is " _(L"Tried to use terminfo string %s on line %ld of %s, which is "
L"undefined in terminal of type \"%ls\". Please report this error to %s"); L"undefined in terminal of type \"%ls\". Please report this error to %s");
debug(0, fmt, mbs_name, line, file, term ? term->as_string().c_str() : L"", FLOG(error, fmt, mbs_name, line, file, term ? term->as_string().c_str() : L"",
PACKAGE_BUGREPORT); PACKAGE_BUGREPORT);
} }
} }

View file

@ -8,7 +8,7 @@
#define PARSE_ASSERT(a) assert(a) #define PARSE_ASSERT(a) assert(a)
#define PARSER_DIE() \ #define PARSER_DIE() \
do { \ do { \
debug(0, "Parser dying!"); \ FLOG(error, "Parser dying!"); \
exit_without_destructors(-1); \ exit_without_destructors(-1); \
} while (0) } while (0)

View file

@ -31,6 +31,7 @@
#include "event.h" #include "event.h"
#include "exec.h" #include "exec.h"
#include "expand.h" #include "expand.h"
#include "flog.h"
#include "function.h" #include "function.h"
#include "io.h" #include "io.h"
#include "maybe.h" #include "maybe.h"
@ -358,7 +359,7 @@ parse_execution_result_t parse_execution_context_t::run_block_statement(
} else if (auto header = bheader.try_get_child<g::begin_header, 0>()) { } else if (auto header = bheader.try_get_child<g::begin_header, 0>()) {
ret = run_begin_statement(contents); ret = run_begin_statement(contents);
} else { } else {
debug(0, L"Unexpected block header: %ls\n", bheader.node()->describe().c_str()); FLOG(error, L"Unexpected block header: %ls\n", bheader.node()->describe().c_str());
PARSER_DIE(); PARSER_DIE();
} }
return ret; return ret;
@ -635,7 +636,7 @@ parse_execution_result_t parse_execution_context_t::report_errors(
const parse_error_list_t &error_list) const { const parse_error_list_t &error_list) const {
if (!parser->cancellation_requested) { if (!parser->cancellation_requested) {
if (error_list.empty()) { if (error_list.empty()) {
debug(0, "Error reported but no error text found."); FLOG(error, "Error reported but no error text found.");
} }
// Get a backtrace. // Get a backtrace.
@ -1076,7 +1077,7 @@ parse_execution_result_t parse_execution_context_t::populate_job_process(
break; break;
} }
default: { default: {
debug(0, L"'%ls' not handled by new parser yet.", FLOG(error, L"'%ls' not handled by new parser yet.",
specific_statement.describe().c_str()); specific_statement.describe().c_str());
PARSER_DIE(); PARSER_DIE();
break; break;
@ -1380,7 +1381,7 @@ parse_execution_result_t parse_execution_context_t::eval_node(tnode_t<g::stateme
} else if (auto switchstat = statement.try_get_child<g::switch_statement, 0>()) { } else if (auto switchstat = statement.try_get_child<g::switch_statement, 0>()) {
status = this->run_switch_statement(switchstat); status = this->run_switch_statement(switchstat);
} else { } else {
debug(0, "Unexpected node %ls found in %s", statement.node()->describe().c_str(), FLOG(error, "Unexpected node %ls found in %s", statement.node()->describe().c_str(),
__FUNCTION__); __FUNCTION__);
abort(); abort();
} }

View file

@ -3,6 +3,7 @@
#include <stdio.h> #include <stdio.h>
#include "common.h" #include "common.h"
#include "flog.h"
#include "parse_constants.h" #include "parse_constants.h"
#include "parse_grammar.h" #include "parse_grammar.h"
#include "parse_productions.h" #include "parse_productions.h"
@ -402,7 +403,7 @@ const production_element_t *parse_productions::production_for_token(parse_token_
case parse_token_type_oror: case parse_token_type_oror:
case parse_token_type_end: case parse_token_type_end:
case parse_token_type_terminate: { case parse_token_type_terminate: {
debug(0, "Terminal token type %ls passed to %s", token_type_description(node_type), FLOG(error, "Terminal token type %ls passed to %s", token_type_description(node_type),
__FUNCTION__); __FUNCTION__);
PARSER_DIE(); PARSER_DIE();
break; break;
@ -410,13 +411,13 @@ const production_element_t *parse_productions::production_for_token(parse_token_
case parse_special_type_parse_error: case parse_special_type_parse_error:
case parse_special_type_tokenizer_error: case parse_special_type_tokenizer_error:
case parse_special_type_comment: { case parse_special_type_comment: {
debug(0, "Special type %ls passed to %s\n", token_type_description(node_type), FLOG(error, "Special type %ls passed to %s\n", token_type_description(node_type),
__FUNCTION__); __FUNCTION__);
PARSER_DIE(); PARSER_DIE();
break; break;
} }
case token_type_invalid: { case token_type_invalid: {
debug(0, "token_type_invalid passed to %s", __FUNCTION__); FLOG(error, "token_type_invalid passed to %s", __FUNCTION__);
PARSER_DIE(); PARSER_DIE();
break; break;
} }

View file

@ -13,6 +13,7 @@
#include "common.h" #include "common.h"
#include "fallback.h" #include "fallback.h"
#include "flog.h"
#include "parse_constants.h" #include "parse_constants.h"
#include "parse_productions.h" #include "parse_productions.h"
#include "parse_tree.h" #include "parse_tree.h"
@ -256,7 +257,7 @@ static inline parse_token_type_t parse_token_type_from_tokenizer_token(
case TOK_COMMENT: case TOK_COMMENT:
return parse_special_type_comment; return parse_special_type_comment;
} }
debug(0, "Bad token type %d passed to %s", (int)tokenizer_token_type, __FUNCTION__); FLOG(error, "Bad token type %d passed to %s", (int)tokenizer_token_type, __FUNCTION__);
DIE("bad token type"); DIE("bad token type");
return token_type_invalid; return token_type_invalid;
} }

View file

@ -18,6 +18,7 @@
#include "env.h" #include "env.h"
#include "expand.h" #include "expand.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "flog.h"
#include "path.h" #include "path.h"
#include "wutil.h" // IWYU pragma: keep #include "wutil.h" // IWYU pragma: keep
@ -267,17 +268,17 @@ static void maybe_issue_path_warning(const wcstring &which_dir, const wcstring &
} }
vars.set_one(warning_var_name, ENV_GLOBAL | ENV_EXPORT, L"1"); vars.set_one(warning_var_name, ENV_GLOBAL | ENV_EXPORT, L"1");
debug(0, custom_error_msg.c_str()); FLOG(error, custom_error_msg.c_str());
if (path.empty()) { if (path.empty()) {
debug(0, _(L"Unable to locate the %ls directory."), which_dir.c_str()); FLOG(error, _(L"Unable to locate the %ls directory."), which_dir.c_str());
debug(0, _(L"Please set the %ls or HOME environment variable before starting fish."), FLOG(error, _(L"Please set the %ls or HOME environment variable before starting fish."),
xdg_var.c_str()); xdg_var.c_str());
} else { } else {
const wchar_t *env_var = using_xdg ? xdg_var.c_str() : L"HOME"; const wchar_t *env_var = using_xdg ? xdg_var.c_str() : L"HOME";
debug(0, _(L"Unable to locate %ls directory derived from $%ls: '%ls'."), which_dir.c_str(), FLOG(error, _(L"Unable to locate %ls directory derived from $%ls: '%ls'."),
env_var, path.c_str()); which_dir.c_str(), env_var, path.c_str());
debug(0, _(L"The error was '%s'."), std::strerror(saved_errno)); FLOG(error, _(L"The error was '%s'."), std::strerror(saved_errno));
debug(0, _(L"Please set $%ls to a directory where you have write access."), env_var); FLOG(error, _(L"Please set $%ls to a directory where you have write access."), env_var);
} }
ignore_result(write(STDERR_FILENO, "\n", 1)); ignore_result(write(STDERR_FILENO, "\n", 1));
} }

View file

@ -374,7 +374,7 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
const char *err = safe_strerror(errno); const char *err = safe_strerror(errno);
debug_safe(0, "exec: %s", err); debug_safe(0, "exec: %s", err);
// debug(0, L"The file '%ls' is marked as an executable but could not be run by the // FLOG(error, L"The file '%ls' is marked as an executable but could not be run by the
// operating system.", p->actual_cmd); // operating system.", p->actual_cmd);
break; break;
} }

View file

@ -914,7 +914,7 @@ void proc_sanity_check(const parser_t &parser) {
// More than one foreground job? // More than one foreground job?
if (j->is_foreground() && !(j->is_stopped() || j->is_completed())) { if (j->is_foreground() && !(j->is_stopped() || j->is_completed())) {
if (fg_job) { if (fg_job) {
debug(0, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"), FLOG(error, _(L"More than one job in foreground: job 1: '%ls' job 2: '%ls'"),
fg_job->command_wcstr(), j->command_wcstr()); fg_job->command_wcstr(), j->command_wcstr());
sanity_lose(); sanity_lose();
} }
@ -928,13 +928,13 @@ void proc_sanity_check(const parser_t &parser) {
validate_pointer(p->argv0(), _(L"Process name"), null_ok); validate_pointer(p->argv0(), _(L"Process name"), null_ok);
if ((p->stopped & (~0x00000001)) != 0) { if ((p->stopped & (~0x00000001)) != 0) {
debug(0, _(L"Job '%ls', process '%ls' has inconsistent state \'stopped\'=%d"), FLOG(error, _(L"Job '%ls', process '%ls' has inconsistent state \'stopped\'=%d"),
j->command_wcstr(), p->argv0(), p->stopped); j->command_wcstr(), p->argv0(), p->stopped);
sanity_lose(); sanity_lose();
} }
if ((p->completed & (~0x00000001)) != 0) { if ((p->completed & (~0x00000001)) != 0) {
debug(0, _(L"Job '%ls', process '%ls' has inconsistent state \'completed\'=%d"), FLOG(error, _(L"Job '%ls', process '%ls' has inconsistent state \'completed\'=%d"),
j->command_wcstr(), p->argv0(), p->completed); j->command_wcstr(), p->argv0(), p->completed);
sanity_lose(); sanity_lose();
} }

View file

@ -52,6 +52,7 @@
#include "exec.h" #include "exec.h"
#include "expand.h" #include "expand.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "flog.h"
#include "function.h" #include "function.h"
#include "global_safety.h" #include "global_safety.h"
#include "highlight.h" #include "highlight.h"
@ -1749,7 +1750,7 @@ static void reader_interactive_init() {
if (shell_pgid == 0) { if (shell_pgid == 0) {
shell_pgid = getpid(); shell_pgid = getpid();
if (setpgid(shell_pgid, shell_pgid) < 0) { if (setpgid(shell_pgid, shell_pgid) < 0) {
debug(0, _(L"Failed to assign shell to its own process group")); FLOG(error, _(L"Failed to assign shell to its own process group"));
wperror(L"setpgid"); wperror(L"setpgid");
exit_without_destructors(1); exit_without_destructors(1);
} }
@ -1759,7 +1760,7 @@ static void reader_interactive_init() {
if (errno == ENOTTY) { if (errno == ENOTTY) {
redirect_tty_output(); redirect_tty_output();
} }
debug(0, _(L"Failed to take control of the terminal")); FLOG(error, _(L"Failed to take control of the terminal"));
wperror(L"tcsetpgrp"); wperror(L"tcsetpgrp");
exit_without_destructors(1); exit_without_destructors(1);
} }

View file

@ -5,6 +5,7 @@
#include "common.h" #include "common.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "flog.h"
#include "global_safety.h" #include "global_safety.h"
#include "history.h" #include "history.h"
#include "kill.h" #include "kill.h"
@ -16,19 +17,19 @@
static relaxed_atomic_bool_t insane{false}; static relaxed_atomic_bool_t insane{false};
void sanity_lose() { void sanity_lose() {
debug(0, _(L"Errors detected, shutting down. Break on sanity_lose() to debug.")); FLOG(error, _(L"Errors detected, shutting down. Break on sanity_lose() to debug."));
insane = true; insane = true;
} }
void validate_pointer(const void *ptr, const wchar_t *err, int null_ok) { void validate_pointer(const void *ptr, const wchar_t *err, int null_ok) {
// Test if the pointer data crosses a segment boundary. // Test if the pointer data crosses a segment boundary.
if ((0x00000003l & (intptr_t)ptr) != 0) { if ((0x00000003l & (intptr_t)ptr) != 0) {
debug(0, _(L"The pointer '%ls' is invalid"), err); FLOG(error, _(L"The pointer '%ls' is invalid"), err);
sanity_lose(); sanity_lose();
} }
if ((!null_ok) && (ptr == 0)) { if ((!null_ok) && (ptr == 0)) {
debug(0, _(L"The pointer '%ls' is null"), err); FLOG(error, _(L"The pointer '%ls' is null"), err);
sanity_lose(); sanity_lose();
} }
} }

View file

@ -243,7 +243,7 @@ tok_t tokenizer_t::read_string() {
} else { } else {
msg.push_back(L'\n'); msg.push_back(L'\n');
} }
debug(0, msg.c_str(), c, c, int(mode_begin), int(mode)); FLOG(error, msg.c_str(), c, c, int(mode_begin), int(mode));
#endif #endif
this->buff++; this->buff++;

View file

@ -27,6 +27,7 @@
#include "common.h" #include "common.h"
#include "fallback.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep
#include "flog.h"
#include "wutil.h" // IWYU pragma: keep #include "wutil.h" // IWYU pragma: keep
typedef std::string cstring; typedef std::string cstring;
@ -130,7 +131,7 @@ const wcstring wgetcwd() {
return str2wcstring(res); return str2wcstring(res);
} }
debug(0, _(L"getcwd() failed with errno %d/%s"), errno, std::strerror(errno)); FLOG(error, _(L"getcwd() failed with errno %d/%s"), errno, std::strerror(errno));
return wcstring(); return wcstring();
} }