summaryrefslogtreecommitdiff
path: root/util/crossgcc/patches/gdb-7.4.1_pythonhome.patch
blob: 9bab2e022cf3722989d0cf92fb8d78aac6921a2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff -ur gdb-7.4.1.orig/gdb/python/python.c gdb-7.4.1/gdb/python/python.c
--- gdb-7.4.1.orig/gdb/python/python.c	2012-01-15 02:04:05.000000000 +0800
+++ gdb-7.4.1/gdb/python/python.c	2012-08-21 15:11:32.000000000 +0800
@@ -1273,6 +1273,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 ();