14 static std::jmp_buf gPanicEnv = {};
21 std::longjmp(gPanicEnv, 1);
27 if (std::setjmp(gPanicEnv))
49 for (
size_t i = 0; i < info.sources.count(); i++)
70 for (
size_t stage = 0; stage <
ePassCount; stage++)
103 static void trace_callback(
bt_address_t frame,
void *user)
109 text_t path = symbol.path;
110 text_t name = symbol.name;
115 .symbol = std::string(name.text, name.
length),
116 .file = std::string(path.text, path.
length),
119 info->frames.push_back(stack_frame);
132 bt_read(trace_callback, &capture);
147 static const ImGuiTableFlags kTableFlags
148 = ImGuiTableFlags_BordersV
149 | ImGuiTableFlags_BordersOuterH
150 | ImGuiTableFlags_Resizable
151 | ImGuiTableFlags_RowBg
152 | ImGuiTableFlags_NoHostExtendX
153 | ImGuiTableFlags_NoBordersInBody
154 | ImGuiTableFlags_SizingStretchProp;
158 if (ImGui::BeginTable(
"Backtrace", 4, kTableFlags))
160 ImGui::TableSetupColumn(
"Address", ImGuiTableColumnFlags_WidthFixed, 150.0f);
161 ImGui::TableSetupColumn(
"Symbol");
162 ImGui::TableSetupColumn(
"File");
163 ImGui::TableSetupColumn(
"Line");
165 ImGui::TableHeadersRow();
169 ImGui::TableNextRow();
171 ImGui::TableNextColumn();
172 ImGui::Text(
"0x%p",
reinterpret_cast<void*
>(frame.address));
174 ImGui::TableNextColumn();
175 ImGui::Text(
"%s", frame.symbol.c_str());
177 ImGui::TableNextColumn();
178 ImGui::Text(
"%s", frame.file.c_str());
180 ImGui::TableNextColumn();
181 ImGui::Text(
"%zu", frame.line);
bool check_reports() const
check if there are any reports
char * parse_source(size_t index)
parse a source file
std::vector< stack_frame_t > frames
void capture_trace(source_info_t location, const char *fmt, va_list args)
uint_least64_t bt_address_t
an address of a symbol
CT_BACKTRACE_API bt_resolve_t bt_resolve_symbol(bt_address_t frame, bt_symbol_t *symbol)
resolve a frame to a symbol
CT_BACKTRACE_API void bt_read(bt_trace_t callback, void *user)
get a backtrace from the current location using a callback
CT_BROKER_API void broker_run_pass(broker_t *broker, broker_pass_t pass)
CT_BROKER_API void broker_resolve(broker_t *broker)
CT_MEMORY_API arena_t * get_global_arena(void)
get the global memory arena
CT_BASE_API panic_handler_t gPanicHandler
the global panic handler.
CT_NODISCARD STA_FORMAT_STRING const char * fmt
CT_NODISCARD STA_FORMAT_STRING const char CT_NODISCARD CT_STD_API char * str_vformat(arena_t *arena, const char *fmt, va_list args)
format a string
void install_panic_handler()
CompileError run_compile(Broker &info)
panic location information
size_t length
the number of characters in the text