MCPcopy Create free account
hub / github.com/DFHack/dfhack / dfhack_save_crashlog

Function dfhack_save_crashlog

library/Crashlog.cpp:112–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void dfhack_save_crashlog() {
113 char** backtrace_strings = backtrace_symbols(crash_info.backtrace, crash_info.backtrace_entries);
114 try {
115 std::filesystem::path crashlog_path = get_crashlog_path();
116 std::ofstream crashlog(crashlog_path);
117
118 crashlog << "Dwarf Fortress Linux has crashed!" << "\n";
119 crashlog << "Dwarf Fortress Version " << DFHack::Version::df_version() << "\n";
120 crashlog << "DFHack Version " << DFHack::Version::dfhack_version() << "\n\n";
121
122 std::string signal = signal_name(crash_info.signal);
123 if (!signal.empty()) {
124 crashlog << "Signal " << signal << "\n";
125 }
126
127 if (crash_info.backtrace_entries >= 2 && backtrace_strings != nullptr) {
128 // Skip the first backtrace entry as it will always be dfhack_crashlog_handle_(signal|terminate)
129 for (int i = 1; i < crash_info.backtrace_entries; i++) {
130 crashlog << i - 1 << "> " << backtrace_strings[i] << "\n";
131 }
132 } else {
133 // Make it clear if no relevant backtrace was able to be obtained
134 crashlog << "Failed to obtain relevant backtrace\n";
135 }
136 } catch (...) {}
137
138 free(backtrace_strings);
139}
140
141void dfhack_crashlog_thread() {
142 // Wait for activation signal

Callers 1

dfhack_crashlog_threadFunction · 0.85

Calls 5

get_crashlog_pathFunction · 0.85
df_versionFunction · 0.85
dfhack_versionFunction · 0.85
signal_nameFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected