diff -u -r -N gdb-7.3.1-org//bfd/hosts/x86-64linux.h gdb-7.3.1-patched//bfd/hosts/x86-64linux.h
--- gdb-7.3.1-org//bfd/hosts/x86-64linux.h	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//bfd/hosts/x86-64linux.h	2011-09-22 22:17:38.648841814 +0000
@@ -147,6 +147,10 @@
     int tv_usec;
   };
 
+#ifndef __pid_t
+#define __pid_t pid_t
+#endif
+
 struct elf_prstatus32
   {
     struct elf_siginfo pr_info;		/* Info associated with signal.  */
diff -u -r -N gdb-7.3.1-org//gdb/amd64-linux-nat.c gdb-7.3.1-patched//gdb/amd64-linux-nat.c
--- gdb-7.3.1-org//gdb/amd64-linux-nat.c	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/amd64-linux-nat.c	2011-09-22 22:20:23.438841813 +0000
@@ -32,7 +32,7 @@
 #include "elf/common.h"
 #include <sys/uio.h>
 #include <sys/ptrace.h>
-#include <sys/debugreg.h>
+#include "debugreg.h"
 #include <sys/syscall.h>
 #include <sys/procfs.h>
 #include <asm/prctl.h>
diff -u -r -N gdb-7.3.1-org//gdb/debugreg.h gdb-7.3.1-patched//gdb/debugreg.h
--- gdb-7.3.1-org//gdb/debugreg.h	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/debugreg.h	2011-09-22 22:20:01.381841813 +0000
@@ -0,0 +1,48 @@
+#ifndef SYS_DEBUGREG_H
+#define SYS_DEBUGREG_H
+
+#include <stdint.h>
+
+#define DR_FIRSTADDR 0
+#define DR_LASTADDR 3
+
+#define DR_STATUS 6
+#define DR_CONTROL 7
+
+#define DR_TRAP0        (0x1)
+#define DR_TRAP1        (0x2)
+#define DR_TRAP2        (0x4)
+#define DR_TRAP3        (0x8)
+
+#define DR_STEP         (0x4000)
+#define DR_SWITCH       (0x8000)
+
+#define DR_CONTROL_SHIFT 16
+#define DR_CONTROL_SIZE  4
+
+#define DR_RW_EXECUTE   (0x0)
+#define DR_RW_WRITE     (0x1)
+#define DR_RW_READ      (0x3)
+
+#define DR_LEN_1 (0x0)
+#define DR_LEN_2 (0x4)
+#define DR_LEN_4 (0xC)
+#define DR_LEN_8 (0x8)
+
+#define DR_LOCAL_ENABLE_SHIFT  0
+#define DR_GLOBAL_ENABLE_SHIFT 1
+#define DR_ENABLE_SIZE         2
+
+#define DR_LOCAL_ENABLE_MASK  (0x55)
+#define DR_GLOBAL_ENABLE_MASK (0xAA)
+
+
+#if SIZE_MAX > 4294967295
+# define DR_CONTROL_RESERVED (0xFFFFFFFF0000FC00UL)
+#else
+# define DR_CONTROL_RESERVED (0x00FC00U)
+#endif
+#define DR_LOCAL_SLOWDOWN   (0x100)
+#define DR_GLOBAL_SLOWDOWN  (0x200)
+
+#endif
diff -u -r -N gdb-7.3.1-org//gdb/gdb_thread_db.h gdb-7.3.1-patched//gdb/gdb_thread_db.h
--- gdb-7.3.1-org//gdb/gdb_thread_db.h	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/gdb_thread_db.h	2011-09-22 22:17:38.641841813 +0000
@@ -1,3 +1,4 @@
+#include <stdint.h>
 #ifdef HAVE_THREAD_DB_H
 #include <thread_db.h>
 
diff -u -r -N gdb-7.3.1-org//gdb/gdbserver/linux-low.c gdb-7.3.1-patched//gdb/gdbserver/linux-low.c
--- gdb-7.3.1-org//gdb/gdbserver/linux-low.c	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/gdbserver/linux-low.c	2011-09-22 22:17:38.643841814 +0000
@@ -17,6 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include "../stopcode.h"
 #include "server.h"
 #include "linux-low.h"
 
@@ -94,10 +95,6 @@
 #define __WALL          0x40000000 /* Wait for any child.  */
 #endif
 
-#ifndef W_STOPCODE
-#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
-#endif
-
 /* This is the kernel's hard limit.  Not to be confused with
    SIGRTMIN.  */
 #ifndef __SIGRTMIN
@@ -110,6 +107,11 @@
 #endif
 #endif
 
+#ifndef __WCLONE
+#define __WCLONE        0x80000000
+#endif
+
+
 /* ``all_threads'' is keyed by the LWP ID, which we use as the GDB protocol
    representation of the thread ID.
 
diff -u -r -N gdb-7.3.1-org//gdb/gdbserver/linux-x86-low.c gdb-7.3.1-patched//gdb/gdbserver/linux-x86-low.c
--- gdb-7.3.1-org//gdb/gdbserver/linux-x86-low.c	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/gdbserver/linux-x86-low.c	2011-09-22 22:17:38.644841814 +0000
@@ -28,6 +28,8 @@
 #include "i386-xstate.h"
 #include "elf/common.h"
 
+#include "reg.h"
+
 #include "gdb_proc_service.h"
 
 /* Defined in auto-generated file i386-linux.c.  */
diff -u -r -N gdb-7.3.1-org//gdb/gdbserver/reg.h gdb-7.3.1-patched//gdb/gdbserver/reg.h
--- gdb-7.3.1-org//gdb/gdbserver/reg.h	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/gdbserver/reg.h	2011-09-22 22:17:38.644841814 +0000
@@ -0,0 +1,66 @@
+#ifndef REG_H_
+#define REG_H_
+
+#warning using REG H
+
+#ifdef __i386__
+
+#warning 386!
+
+#define EBX 0
+#define ECX 1
+#define EDX 2
+#define ESI 3
+#define EDI 4
+#define EBP 5
+#define EAX 6
+#define DS 7
+#define ES 8
+#define FS 9
+#define GS 10
+#define ORIG_EAX 11
+#define EIP 12
+#define CS  13
+#define EFL 14
+#define UESP 15
+#define SS   16
+#define FRAME_SIZE 17
+
+#else /* __i386__ */
+
+#warning not i386!
+
+#if defined(__ASSEMBLY__) || defined(__FRAME_OFFSETS)
+#define R15 0
+#define R14 8
+#define R13 16
+#define R12 24
+#define RBP 32
+#define RBX 40
+/* arguments: interrupts/non tracing syscalls only save upto here*/
+#define R11 48
+#define R10 56
+#define R9 64
+#define R8 72
+#define RAX 80
+#define RCX 88
+#define RDX 96
+#define RSI 104
+#define RDI 112
+#define ORIG_RAX 120       /* = ERROR */
+/* end of arguments */
+/* cpu exception frame or undefined in case of fast syscall. */
+#define RIP 128
+#define CS 136
+#define EFLAGS 144
+#define RSP 152
+#define SS 160
+#define ARGOFFSET R11
+#endif /* __ASSEMBLY__ */
+
+/* top of stack page */
+#define FRAME_SIZE 168
+
+#endif /* !__i386__ */
+
+#endif
diff -u -r -N gdb-7.3.1-org//gdb/gdbserver/stamp-h gdb-7.3.1-patched//gdb/gdbserver/stamp-h
--- gdb-7.3.1-org//gdb/gdbserver/stamp-h	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/gdbserver/stamp-h	2011-09-22 22:17:38.644841814 +0000
@@ -0,0 +1 @@
+
diff -u -r -N gdb-7.3.1-org//gdb/gdbserver/thread-db.c gdb-7.3.1-patched//gdb/gdbserver/thread-db.c
--- gdb-7.3.1-org//gdb/gdbserver/thread-db.c	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/gdbserver/thread-db.c	2011-09-22 22:17:38.645841814 +0000
@@ -21,6 +21,8 @@
 
 #include "server.h"
 
+#include "../threadpathhack.h"
+
 #include "linux-low.h"
 
 extern int debug_threads;
@@ -313,7 +315,10 @@
     return 0;
 
   lwp->thread_known = 1;
+
+#ifdef HAVE_THREAD_DB_H
   lwp->th = th;
+#endif
 
   return 1;
 }
@@ -338,7 +343,9 @@
     }
 
   lwp->thread_known = 1;
+#ifdef HAVE_THREAD_DB_H
   lwp->th = *th_p;
+#endif
 
   if (thread_db_use_events)
     {
@@ -508,12 +515,20 @@
 
   saved_inferior = current_inferior;
   current_inferior = thread;
+
+#ifdef HAVE_THREAD_DB_H
+
   /* Note the cast through uintptr_t: this interface only works if
      a target address fits in a psaddr_t, which is a host pointer.
      So a 32-bit debugger can not access 64-bit TLS through this.  */
+
   err = thread_db->td_thr_tls_get_addr_p (&lwp->th,
 					  (psaddr_t) (uintptr_t) load_module,
 					  offset, &addr);
+
+#else
+	err = ~TD_OK;
+#endif
   current_inferior = saved_inferior;
   if (err == TD_OK)
     {
diff -u -r -N gdb-7.3.1-org//gdb/linux-nat.c gdb-7.3.1-patched//gdb/linux-nat.c
--- gdb-7.3.1-org//gdb/linux-nat.c	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/linux-nat.c	2011-09-22 22:17:38.647841814 +0000
@@ -18,6 +18,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#include "stopcode.h"
 #include "defs.h"
 #include "inferior.h"
 #include "target.h"
@@ -68,6 +69,10 @@
 # endif
 #endif /* HAVE_PERSONALITY */
 
+#ifndef __SIGRTMIN
+#define __SIGRTMIN SIGRTMIN
+#endif
+
 /* This comment documents high-level logic of this file.
 
 Waiting for events in sync mode
diff -u -r -N gdb-7.3.1-org//gdb/linux-thread-db.c gdb-7.3.1-patched//gdb/linux-thread-db.c
--- gdb-7.3.1-org//gdb/linux-thread-db.c	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/linux-thread-db.c	2011-09-22 22:17:38.648841814 +0000
@@ -47,6 +47,8 @@
 #include <gnu/libc-version.h>
 #endif
 
+#include "threadpathhack.h"
+
 /* GNU/Linux libthread_db support.
 
    libthread_db is a library, provided along with libpthread.so, which
@@ -632,10 +634,10 @@
 static const char *
 dladdr_to_soname (const void *addr)
 {
-  Dl_info info;
+/*  Dl_info info;
 
   if (dladdr (addr, &info) != 0)
-    return info.dli_fname;
+    return info.dli_fname; */
   return NULL;
 }
 
diff -u -r -N gdb-7.3.1-org//gdb/stopcode.h gdb-7.3.1-patched//gdb/stopcode.h
--- gdb-7.3.1-org//gdb/stopcode.h	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/stopcode.h	2011-09-22 22:17:38.648841814 +0000
@@ -0,0 +1,4 @@
+#ifndef W_STOPCODE
+#define W_STOPCODE(sig) ((sig) << 8 | 0x7f)
+#endif
+
diff -u -r -N gdb-7.3.1-org//gdb/threadpathhack.h gdb-7.3.1-patched//gdb/threadpathhack.h
--- gdb-7.3.1-org//gdb/threadpathhack.h	1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.3.1-patched//gdb/threadpathhack.h	2011-09-22 22:17:38.648841814 +0000
@@ -0,0 +1,15 @@
+#ifndef HACK_PATH_SO
+#define HACK_PATH_SO
+
+#ifndef LIBTHREAD_DB_SO
+#define LIBTHREAD_DB_SO "bug.so"
+#endif
+#ifndef LIBTHREAD_DB_SEARCH_PATH
+#define LIBTHREAD_DB_SEARCH_PATH "/lib"
+#endif
+
+#endif
+
+
+
+
