aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorWeimin Pan <weimin.pan@oracle.com>2022-09-27 14:58:04 -0700
committerIndu Bhagat <indu.bhagat@oracle.com>2024-04-25 15:03:50 -0700
commit6d551065a7add22cef04864d850400443cdd065b (patch)
tree27004ca592171343d5b5205e9f798d4af075a2f9 /include
parentdffb4a0784f401c2aa20446abb651a4e19f34a44 (diff)
downloadbinutils-6d551065a7add22cef04864d850400443cdd065b.zip
binutils-6d551065a7add22cef04864d850400443cdd065b.tar.gz
binutils-6d551065a7add22cef04864d850400443cdd065b.tar.bz2
unwinder: generate backtrace using SFrame format
[Changes in V4] - Renamed ESFRAME_* enum error code names to SFRAME_ERR_*. - Addressed review comments by Mike. - Use AC_CACHE_CHECK macro in sframe.m4 - Delete config/sframe.m4. Add into libsframe/acinclude.m4. - Code fixups. [End of changes in V4] [Changes in V3] - Use the updated APIs from libsframe. - Use sframe_decoder_get_fixed_ra_offset on AMD64 instead of magic number -8. [End of changes in V3] [Changes in V2] - Minor formatting fixes. [End of changes in V2] A simple unwinder based on SFrame format. The unwinder is made available via libsframebt library. Buildsystem changes have been made to build libsframebt only when --gsframe support is available in the assembler. These buildsystem changes are necessary because the SFrame based unwinder the SFrame unwind info for itself to work. include/ChangeLog: * sframe-backtrace-api.h: New file. ChangeLog: * libsframe/acinclude.m4: New file. * libsframe/Makefile.am: Build backtrace functionality in its own library. Install libsframebt conditionally. * libsframe/Makefile.in: Regenerate. * libsframe/aclocal.m4: Regenerate. * libsframe/configure: Regenerate. * libsframe/configure.ac: Check if gas supports --gsframe command line option. * libsframe/sframe-backtrace-err.c: New file. * libsframe/sframe-backtrace.c: New file.
Diffstat (limited to 'include')
-rw-r--r--include/sframe-backtrace-api.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/sframe-backtrace-api.h b/include/sframe-backtrace-api.h
new file mode 100644
index 0000000..b9537bf
--- /dev/null
+++ b/include/sframe-backtrace-api.h
@@ -0,0 +1,60 @@
+/* Public API to SFrame backtrace.
+
+ Copyright (C) 2022 Free Software Foundation, Inc.
+
+ This file is part of libsframebt.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef _SFRAME_BACKTRACE_API_H
+#define _SFRAME_BACKTRACE_API_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+enum sframe_bt_errcode
+{
+ SFRAME_BT_OK,
+ SFRAME_BT_ERR_NOTPRESENT,
+ SFRAME_BT_ERR_ARG,
+ SFRAME_BT_ERR_MALLOC,
+ SFRAME_BT_ERR_REALLOC,
+ SFRAME_BT_ERR_OPEN,
+ SFRAME_BT_ERR_READLINK,
+ SFRAME_BT_ERR_LSEEK,
+ SFRAME_BT_ERR_READ,
+ SFRAME_BT_ERR_GETCONTEXT,
+ SFRAME_BT_ERR_DECODE,
+ SFRAME_BT_ERR_CFA_OFFSET,
+};
+
+#define NUM_OF_DSOS 32 /* Number of DSOs. */
+
+#define ENUM_ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+/* Get the backtrace of the calling program by storing return addresses
+ in BUFFER. The SIZE argument specifies the maximum number of addresses
+ that can be stored in the buffer. Return the number of return addresses
+ collected or -1 if there is any error. */
+extern int sframe_backtrace (void **buffer, int size, int *errp);
+
+extern const char *sframe_bt_errmsg (enum sframe_bt_errcode ecode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SFRAME_BACKTRACE_API_H */