Ken Van Hoeylandt c87200a80d
Project restructuring (fixes macOS builds) (#198)
- Create `Include/` folder for all main projects
- Fix some issues here and there (found while moving things)
- All includes are now in `Tactility/` subfolder and must be included with that prefix. This fixes issues with clashing POSIX headers (e.g. `<semaphore.h>` versus Tactility's `Semaphore.h`)
2025-02-01 18:13:20 +01:00

50 lines
1.3 KiB
C++

#ifdef ESP_PLATFORM
#include "Tactility/app/crashdiagnostics/QrUrl.h"
#include <Tactility/kernel/PanicHandler.h>
#include <sstream>
#include <esp_cpu_utils.h>
#include <sdkconfig.h>
std::string getUrlFromCrashData() {
auto crash_data = getRtcCrashData();
auto* stack_buffer = (uint32_t*) malloc(crash_data.callstackLength * 2 * sizeof(uint32_t));
for (int i = 0; i < crash_data.callstackLength; ++i) {
const CallstackFrame&frame = crash_data.callstack[i];
uint32_t pc = esp_cpu_process_stack_pc(frame.pc);
#if CRASH_DATA_INCLUDES_SP
uint32_t sp = frame.sp;
#endif
stack_buffer[i * 2] = pc;
#if CRASH_DATA_INCLUDES_SP
stack_buffer[(i * 2) + 1] = sp;
#endif
}
std::stringstream stream;
stream << "https://oops.tactility.one";
stream << "?v=" << TT_VERSION; // Version
stream << "&a=" << CONFIG_IDF_TARGET; // Architecture
stream << "&b=" << CONFIG_TT_BOARD_ID; // Board identifier
stream << "&s="; // Stacktrace
for (int i = crash_data.callstackLength - 1; i >= 0; --i) {
uint32_t pc = stack_buffer[(i * 2)];
stream << std::hex << pc;
#if CRASH_DATA_INCLUDES_SP
uint32_t sp = stack_buffer[(i * 2) + 1];
stream << std::hex << sp;
#endif
}
free(stack_buffer);
return stream.str();
}
#endif