mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 12:18:31 +00:00
Improve debug binary location detection
This commit is contained in:
parent
68c7c9c1e0
commit
7a9e176ecf
17 changed files with 92 additions and 50 deletions
|
@ -22,6 +22,7 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
|
@ -46,10 +47,9 @@ relegated wontreturn void __die(void) {
|
|||
strcpy(host, "unknown");
|
||||
gethostname(host, sizeof(host));
|
||||
kprintf("%serror: %s on %s pid %d tid %d has perished%s\n"
|
||||
"cosmoaddr2line %s%s %s\n",
|
||||
"cosmoaddr2line %s %s\n",
|
||||
__nocolor ? "" : "\e[1;31m", program_invocation_short_name, host,
|
||||
getpid(), gettid(), __nocolor ? "" : "\e[0m", __argv[0],
|
||||
endswith(__argv[0], ".com") ? ".dbg" : "",
|
||||
getpid(), gettid(), __nocolor ? "" : "\e[0m", FindDebugBinary(),
|
||||
DescribeBacktrace(__builtin_frame_address(0)));
|
||||
_Exit(77);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "libc/log/internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
|
@ -64,12 +65,12 @@ relegated dontinstrument void __minicrash(int sig, siginfo_t *si, void *arg) {
|
|||
gethostname(host, sizeof(host));
|
||||
kprintf(
|
||||
"%serror: %s on %s pid %d tid %d got %G%s code %d addr %p%s\n"
|
||||
"cosmoaddr2line %s%s %lx %s\n",
|
||||
"cosmoaddr2line %s %lx %s\n",
|
||||
__nocolor ? "" : "\e[1;31m", program_invocation_short_name, host,
|
||||
getpid(), gettid(), sig,
|
||||
__is_stack_overflow(si, ctx) ? " (stack overflow)" : "", si->si_code,
|
||||
si->si_addr, __nocolor ? "" : "\e[0m", __argv[0],
|
||||
endswith(__argv[0], ".com") ? ".dbg" : "", ctx ? ctx->uc_mcontext.PC : 0,
|
||||
si->si_addr, __nocolor ? "" : "\e[0m", FindDebugBinary(),
|
||||
ctx ? ctx->uc_mcontext.PC : 0,
|
||||
DescribeBacktrace(ctx ? (struct StackFrame *)ctx->uc_mcontext.BP
|
||||
: (struct StackFrame *)__builtin_frame_address(0)));
|
||||
}
|
||||
|
|
|
@ -74,8 +74,8 @@ static const char kFpuExceptions[6] forcealign(1) = "IDZOUP";
|
|||
|
||||
relegated static void ShowFunctionCalls(ucontext_t *ctx) {
|
||||
kprintf(
|
||||
"cosmoaddr2line %s%s %lx %s\n\n", __argv[0],
|
||||
endswith(__argv[0], ".com") ? ".dbg" : "", ctx ? ctx->uc_mcontext.PC : 0,
|
||||
"cosmoaddr2line %s %lx %s\n\n", FindDebugBinary(),
|
||||
ctx ? ctx->uc_mcontext.PC : 0,
|
||||
DescribeBacktrace(ctx ? (struct StackFrame *)ctx->uc_mcontext.BP
|
||||
: (struct StackFrame *)__builtin_frame_address(0)));
|
||||
ShowBacktrace(2, &(struct StackFrame){
|
||||
|
|
|
@ -229,8 +229,8 @@ static relegated void __oncrash_impl(int sig, struct siginfo *si,
|
|||
Append(b, " %s %s %s %s\n", names.sysname, names.version, names.nodename,
|
||||
names.release);
|
||||
Append(
|
||||
b, " cosmoaddr2line %s%s %lx %s\n", __argv[0],
|
||||
endswith(__argv[0], ".com") ? ".dbg" : "", ctx ? ctx->uc_mcontext.PC : 0,
|
||||
b, " cosmoaddr2line %s %lx %s\n", FindDebugBinary(),
|
||||
ctx ? ctx->uc_mcontext.PC : 0,
|
||||
DescribeBacktrace(ctx ? (struct StackFrame *)ctx->uc_mcontext.BP
|
||||
: (struct StackFrame *)__builtin_frame_address(0)));
|
||||
if (ctx) {
|
||||
|
|
|
@ -76,6 +76,7 @@ static void InstallCrashHandler(int sig, int flags) {
|
|||
void ShowCrashReports(void) {
|
||||
struct sigaltstack ss;
|
||||
static char crashstack[65536];
|
||||
FindDebugBinary();
|
||||
ss.ss_flags = 0;
|
||||
ss.ss_size = sizeof(crashstack);
|
||||
ss.ss_sp = crashstack;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue