mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Update libbacktrace to dedbe13fda.
This commit is contained in:
committed by
Bartosz Taudul
parent
a3bfbab6bd
commit
8bacc7a91c
+65
-19
@@ -1,5 +1,5 @@
|
||||
/* fileline.c -- Get file and line number information in a backtrace.
|
||||
Copyright (C) 2012-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 2012-2021 Free Software Foundation, Inc.
|
||||
Written by Ian Lance Taylor, Google.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -43,28 +43,15 @@ POSSIBILITY OF SUCH DAMAGE. */
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MACH_O_DYLD_H
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#include "backtrace.hpp"
|
||||
#include "internal.hpp"
|
||||
|
||||
#ifndef HAVE_GETEXECNAME
|
||||
# ifdef __APPLE__
|
||||
# include <mach-o/dyld.h>
|
||||
static const char* getexecname()
|
||||
{
|
||||
static char execname[PATH_MAX+1];
|
||||
uint32_t size = sizeof( execname );
|
||||
if( _NSGetExecutablePath( execname, &size ) == 0 )
|
||||
{
|
||||
return execname;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
# else
|
||||
#define getexecname() NULL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace tracy
|
||||
@@ -142,6 +129,35 @@ sysctl_exec_name2 (struct backtrace_state *state,
|
||||
|
||||
#endif /* defined (HAVE_KERN_PROC_ARGS) || |defined (HAVE_KERN_PROC) */
|
||||
|
||||
#ifdef HAVE_MACH_O_DYLD_H
|
||||
|
||||
static char *
|
||||
macho_get_executable_path (struct backtrace_state *state,
|
||||
backtrace_error_callback error_callback, void *data)
|
||||
{
|
||||
uint32_t len;
|
||||
char *name;
|
||||
|
||||
len = 0;
|
||||
if (_NSGetExecutablePath (NULL, &len) == 0)
|
||||
return NULL;
|
||||
name = (char *) backtrace_alloc (state, len, error_callback, data);
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
if (_NSGetExecutablePath (name, &len) != 0)
|
||||
{
|
||||
backtrace_free (state, name, len, error_callback, data);
|
||||
return NULL;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
#else /* !defined (HAVE_MACH_O_DYLD_H) */
|
||||
|
||||
#define macho_get_executable_path(state, error_callback, data) NULL
|
||||
|
||||
#endif /* !defined (HAVE_MACH_O_DYLD_H) */
|
||||
|
||||
/* Initialize the fileline information from the executable. Returns 1
|
||||
on success, 0 on failure. */
|
||||
|
||||
@@ -179,7 +195,7 @@ fileline_initialize (struct backtrace_state *state,
|
||||
|
||||
descriptor = -1;
|
||||
called_error_callback = 0;
|
||||
for (pass = 0; pass < 7; ++pass)
|
||||
for (pass = 0; pass < 8; ++pass)
|
||||
{
|
||||
int does_not_exist;
|
||||
|
||||
@@ -208,6 +224,9 @@ fileline_initialize (struct backtrace_state *state,
|
||||
case 6:
|
||||
filename = sysctl_exec_name2 (state, error_callback, data);
|
||||
break;
|
||||
case 7:
|
||||
filename = macho_get_executable_path (state, error_callback, data);
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
@@ -302,4 +321,31 @@ backtrace_syminfo (struct backtrace_state *state, uintptr_t pc,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* A backtrace_syminfo_callback that can call into a
|
||||
backtrace_full_callback, used when we have a symbol table but no
|
||||
debug info. */
|
||||
|
||||
void
|
||||
backtrace_syminfo_to_full_callback (void *data, uintptr_t pc,
|
||||
const char *symname,
|
||||
uintptr_t symval ATTRIBUTE_UNUSED,
|
||||
uintptr_t symsize ATTRIBUTE_UNUSED)
|
||||
{
|
||||
struct backtrace_call_full *bdata = (struct backtrace_call_full *) data;
|
||||
|
||||
bdata->ret = bdata->full_callback (bdata->full_data, pc, 0, NULL, 0, symname);
|
||||
}
|
||||
|
||||
/* An error callback that corresponds to
|
||||
backtrace_syminfo_to_full_callback. */
|
||||
|
||||
void
|
||||
backtrace_syminfo_to_full_error_callback (void *data, const char *msg,
|
||||
int errnum)
|
||||
{
|
||||
struct backtrace_call_full *bdata = (struct backtrace_call_full *) data;
|
||||
|
||||
bdata->full_error_callback (bdata->full_data, msg, errnum);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user