blob: 90da2d9d6f78dc35929e61c9cba47c5761c7c3bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
diff -ur gdb-7.3.1.orig/gdb/python/python.c gdb-7.3.1/gdb/python/python.c
--- gdb-7.3.1.orig/gdb/python/python.c 2011-07-02 21:33:10.000000000 +0200
+++ gdb-7.3.1/gdb/python/python.c 2011-11-01 21:07:25.000000000 +0100
@@ -33,6 +33,7 @@
#include "python.h"
#include <ctype.h>
+#include <libgen.h>
/* True if we should print the stack when catching a Python error,
false otherwise. */
@@ -1010,6 +1011,15 @@
SLASH_STRING, "python", NULL));
#endif
+ char readlinkbuffer[BUFSIZ];
+ int readlinks = readlink("/proc/self/exe", readlinkbuffer, BUFSIZ - 1);
+ readlinkbuffer[readlinks] = 0;
+ char *executeablepath = dirname(readlinkbuffer);
+ char *pythonhome = malloc(strlen(executeablepath) + strlen("/../") + 2);
+ strcpy(pythonhome, executeablepath);
+ strcat(pythonhome, "/../");
+ setenv("PYTHONHOME", pythonhome, 1);
+
Py_Initialize ();
PyEval_InitThreads ();
|