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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
diff --git gdb/Makefile.in gdb/Makefile.in
index 5b6ccea764..f501cf29d1 100644
--- gdb/Makefile.in
+++ gdb/Makefile.in
@@ -212,7 +212,8 @@ INCGNU = -I$(srcdir)/gnulib/import -I$(GNULIB_BUILDDIR)/import
# Generated headers in the gnulib directory. These must be listed
# so that they are generated before other files are compiled.
-GNULIB_H = $(GNULIB_BUILDDIR)/import/string.h @GNULIB_STDINT_H@
+GNULIB_H = $(GNULIB_BUILDDIR)/import/string.h \
+ $(GNULIB_BUILDDIR)/import/alloca.h @GNULIB_STDINT_H@
#
# CLI sub directory definitons
@@ -653,7 +654,8 @@ ALL_64_TARGET_OBS = \
ia64-linux-tdep.o ia64-vms-tdep.o ia64-tdep.o \
mips64obsd-tdep.o \
sparc64fbsd-tdep.o sparc64-linux-tdep.o sparc64nbsd-tdep.o \
- sparc64obsd-tdep.o sparc64-sol2-tdep.o sparc64-tdep.o
+ sparc64obsd-tdep.o sparc64-sol2-tdep.o sparc64-tdep.o \
+ amd64fbsd-kern.o sparc64fbsd-kern.o
# All other target-dependent objects files (used with --enable-targets=all).
ALL_TARGET_OBS = \
@@ -676,6 +678,8 @@ ALL_TARGET_OBS = \
i386-sol2-tdep.o i386-tdep.o i387-tdep.o \
i386-dicos-tdep.o i386-darwin-tdep.o \
iq2000-tdep.o \
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o ppcfbsd-kern.o \
+ mipsfbsd-kern.o \
linux-tdep.o \
lm32-tdep.o \
m32c-tdep.o \
@@ -1133,7 +1137,7 @@ generated_files = config.h observer.h observer.inc ada-lex.c jit-reader.h \
$(COMPILE) $<
$(POSTCOMPILE)
-all: gdb$(EXEEXT) $(CONFIG_ALL)
+all: gdb$(EXEEXT) kgdb$(EXEEXT) $(CONFIG_ALL)
@$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
installcheck:
@@ -1412,6 +1416,12 @@ gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) \
$(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
+kgdb$(EXEEXT): kgdb-main.o $(LIBGDB_OBS) $(ADD_DEPS) $(CDEPS) $(TDEPLIBS)
+ rm -f kgdb$(EXEEXT)
+ $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
+ -o kgdb$(EXEEXT) kgdb-main.o $(LIBGDB_OBS) \
+ $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES)
+
# Convenience rule to handle recursion.
$(LIBGNU) $(GNULIB_H): all-lib
all-lib: $(GNULIB_BUILDDIR)/Makefile
@@ -1456,7 +1466,7 @@ clean mostlyclean: $(CONFIG_CLEAN)
@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
rm -f *.o *.a $(ADD_FILES) *~ init.c-tmp init.l-tmp version.c-tmp
rm -f init.c version.c observer.h observer.inc
- rm -f gdb$(EXEEXT) core make.log
+ rm -f gdb$(EXEEXT) core make.log kgdb$(EXEEXT)
rm -f gdb[0-9]$(EXEEXT)
rm -f test-cp-name-parser$(EXEEXT)
rm -f xml-builtin.c stamp-xml
@@ -1688,6 +1698,9 @@ ALLDEPFILES = \
core-regset.c \
dcache.c dicos-tdep.c darwin-nat.c \
exec.c \
+ fbsd-kld.c fbsd-kthr.c fbsd-kvm.c \
+ amd64fbsd-kern.c i386fbsd-kern.c mipsfbsd-kern.c ppcfbsd-kern.c \
+ sparc64fbsd-kern.c \
fbsd-nat.c \
fbsd-tdep.c \
fork-child.c \
@@ -2761,7 +2774,7 @@ py-varobj.o: $(srcdir)/python/py-varobj.c
# A list of all the objects we might care about in this build, for
# dependency tracking.
-all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \
+all_object_files = kgdb-main.o gdb.o $(LIBGDB_OBS) gdbtk-main.o \
test-cp-name-parser.o
# Ensure that generated files are created early. Use order-only
diff --git gdb/config.in gdb/config.in
index c82a5b4bac..34140b2d59 100644
--- gdb/config.in
+++ gdb/config.in
@@ -219,6 +219,9 @@
/* Define to 1 if your system has the kinfo_getvmmap function. */
#undef HAVE_KINFO_GETVMMAP
+/* Define to 1 if your system has the kvm_open2 function. */
+#undef HAVE_KVM_OPEN2
+
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
diff --git gdb/configure gdb/configure
index b5c045cf10..68299ff16c 100755
--- gdb/configure
+++ gdb/configure
@@ -7112,6 +7112,66 @@ $as_echo "#define HAVE_KINFO_GETVMMAP 1" >>confdefs.h
fi
+# kgdb needs kvm_open2 for cross-debugging
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing kvm_open2" >&5
+$as_echo_n "checking for library containing kvm_open2... " >&6; }
+if test "${ac_cv_search_kvm_open2+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char kvm_open2 ();
+int
+main ()
+{
+return kvm_open2 ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' kvm; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_kvm_open2=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if test "${ac_cv_search_kvm_open2+set}" = set; then :
+ break
+fi
+done
+if test "${ac_cv_search_kvm_open2+set}" = set; then :
+
+else
+ ac_cv_search_kvm_open2=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_kvm_open2" >&5
+$as_echo "$ac_cv_search_kvm_open2" >&6; }
+ac_res=$ac_cv_search_kvm_open2
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+$as_echo "#define HAVE_KVM_OPEN2 1" >>confdefs.h
+
+fi
+
+
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
diff --git gdb/configure.ac gdb/configure.ac
index f774db7ea6..efccdd3fb1 100644
--- gdb/configure.ac
+++ gdb/configure.ac
@@ -540,6 +540,11 @@ AC_SEARCH_LIBS(kinfo_getvmmap, util util-freebsd,
[AC_DEFINE(HAVE_KINFO_GETVMMAP, 1,
[Define to 1 if your system has the kinfo_getvmmap function. ])])
+# kgdb needs kvm_open2 for cross-debugging
+AC_SEARCH_LIBS(kvm_open2, kvm,
+ [AC_DEFINE(HAVE_KVM_OPEN2, 1,
+ [Define to 1 if your system has the kvm_open2 function. ])])
+
AM_ICONV
# GDB may fork/exec the iconv program to get the list of supported character
diff --git gdb/configure.tgt gdb/configure.tgt
index 9ee9f7a799..fb14b19405 100644
--- gdb/configure.tgt
+++ gdb/configure.tgt
@@ -190,7 +190,13 @@ i[34567]86-*-dicos*)
i[34567]86-*-freebsd* | i[34567]86-*-kfreebsd*-gnu)
# Target: FreeBSD/i386
gdb_target_obs="i386-tdep.o i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
- bsd-uthread.o fbsd-tdep.o solib-svr4.o"
+ bsd-uthread.o fbsd-tdep.o solib-svr4.o \
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o i386fbsd-kern.o"
+ if test "x$enable_64_bit_bfd" = "xyes"; then
+ # Target: FreeBSD amd64
+ gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o amd64fbsd-kern.o \
+ ${gdb_target_obs}"
+ fi
;;
i[34567]86-*-netbsd* | i[34567]86-*-knetbsd*-gnu)
# Target: NetBSD/i386
@@ -360,7 +366,8 @@ mips*-*-netbsd* | mips*-*-knetbsd*-gnu)
;;
mips*-*-freebsd*)
# Target: MIPS running FreeBSD
- gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o"
+ gdb_target_obs="mips-tdep.o mips-fbsd-tdep.o solib-svr4.o fbsd-tdep.o \
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o mipsfbsd-kern.o"
gdb_sim=../sim/mips/libsim.a
;;
mips64*-*-openbsd*)
@@ -419,7 +426,8 @@ powerpc*-*-freebsd*)
# Target: FreeBSD/powerpc
gdb_target_obs="rs6000-tdep.o ppc-sysv-tdep.o ppc64-tdep.o \
ppcfbsd-tdep.o fbsd-tdep.o solib-svr4.o \
- ravenscar-thread.o ppc-ravenscar-thread.o"
+ ravenscar-thread.o ppc-ravenscar-thread.o \
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o ppcfbsd-kern.o"
;;
powerpc-*-netbsd* | powerpc-*-knetbsd*-gnu)
@@ -543,7 +551,8 @@ sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
# Target: FreeBSD/sparc64
gdb_target_obs="sparc-tdep.o sparc64-tdep.o sparc64fbsd-tdep.o \
fbsd-tdep.o solib-svr4.o \
- ravenscar-thread.o sparc-ravenscar-thread.o"
+ ravenscar-thread.o sparc-ravenscar-thread.o \
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o sparc64fbsd-kern.o"
;;
sparc-*-netbsd* | sparc-*-knetbsd*-gnu)
# Target: NetBSD/sparc
@@ -674,7 +683,9 @@ x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu)
# Target: FreeBSD/amd64
gdb_target_obs="amd64-tdep.o amd64fbsd-tdep.o i386-tdep.o \
i387-tdep.o i386bsd-tdep.o i386fbsd-tdep.o \
- bsd-uthread.o fbsd-tdep.o solib-svr4.o"
+ bsd-uthread.o fbsd-tdep.o solib-svr4.o \
+ fbsd-kld.o fbsd-kthr.o fbsd-kvm.o amd64fbsd-kern.o \
+ i386fbsd-kern.o"
;;
x86_64-*-mingw* | x86_64-*-cygwin*)
# Target: MingW/amd64
diff --git gdb/defs.h gdb/defs.h
index 9b44f44349..f176be1108 100644
--- gdb/defs.h
+++ gdb/defs.h
@@ -598,6 +598,7 @@ enum gdb_osabi
GDB_OSABI_LINUX,
GDB_OSABI_FREEBSD_AOUT,
GDB_OSABI_FREEBSD_ELF,
+ GDB_OSABI_FREEBSD_ELF_KERNEL,
GDB_OSABI_NETBSD_AOUT,
GDB_OSABI_NETBSD_ELF,
GDB_OSABI_OPENBSD_ELF,
diff --git gdb/osabi.c gdb/osabi.c
index f7d4e74239..130ffef37e 100644
--- gdb/osabi.c
+++ gdb/osabi.c
@@ -66,6 +66,7 @@ static const struct osabi_names gdb_osabi_names[] =
{ "GNU/Linux", "linux(-gnu)?" },
{ "FreeBSD/a.out", NULL },
{ "FreeBSD/ELF", NULL },
+ { "FreeBSD/kernel", NULL },
{ "NetBSD/a.out", NULL },
{ "NetBSD/ELF", NULL },
{ "OpenBSD/ELF", NULL },
diff --git gdb/regcache.c gdb/regcache.c
index a5c90a6314..05044e5293 100644
--- gdb/regcache.c
+++ gdb/regcache.c
@@ -1083,6 +1083,20 @@ regcache_raw_supply (struct regcache *regcache, int regnum, const void *buf)
}
}
+void
+regcache_raw_supply_unsigned (struct regcache *regcache, int regnum,
+ ULONGEST val)
+{
+ gdb_byte *buf;
+
+ gdb_assert (regcache != NULL);
+ gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
+ buf = (gdb_byte *)alloca (regcache->descr->sizeof_register[regnum]);
+ store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch), val);
+ regcache_raw_supply (regcache, regnum, buf);
+}
+
/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
void
diff --git gdb/regcache.h gdb/regcache.h
index 1bb0ce0ec8..65783b6355 100644
--- gdb/regcache.h
+++ gdb/regcache.h
@@ -135,6 +135,8 @@ extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
extern void regcache_raw_supply (struct regcache *regcache,
int regnum, const void *buf);
+extern void regcache_raw_supply_unsigned (struct regcache *regcache,
+ int regnum, ULONGEST val);
extern void regcache_raw_collect (const struct regcache *regcache,
int regnum, void *buf);
|