summaryrefslogtreecommitdiffstats
path: root/perl-install/c
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2011-11-22 20:35:24 +0000
committerThierry Vignaud <tv@mageia.org>2011-11-22 20:35:24 +0000
commit9b8c0657d644440e3625167baf327d6b06f5b546 (patch)
treedad865fd37f15c555c776113036e8ec4d3226f55 /perl-install/c
parentf56bcb324794751943a1cecfff2141fc78821b38 (diff)
downloaddrakx-9b8c0657d644440e3625167baf327d6b06f5b546.tar
drakx-9b8c0657d644440e3625167baf327d6b06f5b546.tar.gz
drakx-9b8c0657d644440e3625167baf327d6b06f5b546.tar.bz2
drakx-9b8c0657d644440e3625167baf327d6b06f5b546.tar.xz
drakx-9b8c0657d644440e3625167baf327d6b06f5b546.zip
(C_backtrace) introduce it in order to get a better GDB trace
Diffstat (limited to 'perl-install/c')
-rwxr-xr-xperl-install/c/stuff.xs.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl
index 1dbc9686a..d3dfd41ab 100755
--- a/perl-install/c/stuff.xs.pl
+++ b/perl-install/c/stuff.xs.pl
@@ -37,6 +37,7 @@ print '
#include <netinet/in.h>
#include <linux/sockios.h>
#include <linux/input.h>
+#include <execinfo.h>
// for ethtool structs:
typedef unsigned long long u64;
@@ -701,6 +702,34 @@ disk_add_partition(char * device_path, double start, double length, const char *
OUTPUT:
RETVAL
+#define BACKTRACE_DEPTH 20
+
+
+char*
+C_backtrace()
+ CODE:
+ static char buf[1024];
+ int nAddresses, i;
+ unsigned long idx = 0;
+ void * addresses[BACKTRACE_DEPTH];
+ char ** symbols = NULL;
+ nAddresses = backtrace(addresses, BACKTRACE_DEPTH);
+ symbols = backtrace_symbols(addresses, nAddresses);
+ if (symbols == NULL) {
+ idx += sprintf(buf+idx, "ERROR: Retrieving symbols failed.\n");
+ } else {
+ fprintf(stderr, "HERE 5\n");
+ /* dump stack trace */
+ for (i = 0; i < nAddresses; ++i)
+ idx += sprintf(buf+idx, "%d: %s\n", i, symbols[i]);
+ }
+ RETVAL = strdup(buf);
+ OUTPUT:
+ RETVAL
+
+
+
+
';
@macros = (