Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libbacktrace
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
libbacktrace
Commits
4ae8d988
Commit
4ae8d988
authored
Sep 08, 2020
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
libbacktrace: fetch executable path on macOS
PR libbacktrace/96973 * fileline.c (macho_get_executable_path): New static function. (fileline_initialize): Call macho_get_executable_path.
parent
430dc8b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
1 deletion
+37
-1
fileline.c
fileline.c
+37
-1
No files found.
fileline.c
View file @
4ae8d988
...
...
@@ -43,6 +43,10 @@ POSSIBILITY OF SUCH DAMAGE. */
#include <sys/sysctl.h>
#endif
#ifdef HAVE_MACH_O_DYLD_H
#include <mach-o/dyld.h>
#endif
#include "backtrace.h"
#include "internal.h"
...
...
@@ -122,6 +126,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. */
...
...
@@ -159,7 +192,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
;
...
...
@@ -188,6 +221,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
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment