PERFORCE change 140903 for review
Sam Leffler
sam at FreeBSD.org
Tue Apr 29 22:27:55 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=140903
Change 140903 by sam at sam_ebb on 2008/04/29 22:27:24
IFC @ 140901
Affected files ...
.. //depot/projects/vap/Makefile#7 integrate
.. //depot/projects/vap/UPDATING#10 integrate
.. //depot/projects/vap/bin/sh/expand.c#3 integrate
.. //depot/projects/vap/games/fortune/datfiles/fortunes#8 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kgdb.h#6 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kld.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kthr.c#5 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/main.c#6 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt.c#5 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_amd64.c#3 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_arm.c#3 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_i386.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_ia64.c#3 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c#3 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c#3 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#3 integrate
.. //depot/projects/vap/lib/libc/stdlib/malloc.c#7 integrate
.. //depot/projects/vap/lib/libc/sys/sctp_generic_recvmsg.2#3 integrate
.. //depot/projects/vap/lib/libc/sys/sctp_peeloff.2#3 integrate
.. //depot/projects/vap/lib/libstand/Makefile#3 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_create.c#6 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_exit.c#7 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_private.h#6 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_resume_np.c#3 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_sem.c#5 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_sig.c#5 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_suspend_np.c#3 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_umtx.c#4 integrate
.. //depot/projects/vap/lib/libthr/thread/thr_umtx.h#4 integrate
.. //depot/projects/vap/share/man/man4/Makefile#13 integrate
.. //depot/projects/vap/share/man/man4/ddb.4#6 integrate
.. //depot/projects/vap/share/man/man4/iwn.4#3 integrate
.. //depot/projects/vap/share/man/man4/termios.4#3 integrate
.. //depot/projects/vap/share/man/man4/uscanner.4#4 integrate
.. //depot/projects/vap/share/man/man9/BUS_SETUP_INTR.9#4 integrate
.. //depot/projects/vap/share/mk/bsd.endian.mk#3 integrate
.. //depot/projects/vap/sys/amd64/conf/NOTES#11 integrate
.. //depot/projects/vap/sys/conf/NOTES#16 integrate
.. //depot/projects/vap/sys/conf/files#37 integrate
.. //depot/projects/vap/sys/conf/files.powerpc#11 integrate
.. //depot/projects/vap/sys/conf/kern.mk#6 integrate
.. //depot/projects/vap/sys/conf/options#21 integrate
.. //depot/projects/vap/sys/contrib/dev/iwn/LICENSE#2 integrate
.. //depot/projects/vap/sys/contrib/dev/iwn/iwlwifi-4965-4.44.17.fw.uu#2 integrate
.. //depot/projects/vap/sys/dev/bge/if_bge.c#12 integrate
.. //depot/projects/vap/sys/dev/bge/if_bgereg.h#9 integrate
.. //depot/projects/vap/sys/dev/iwn/if_iwn.c#13 integrate
.. //depot/projects/vap/sys/dev/iwn/if_iwnreg.h#5 integrate
.. //depot/projects/vap/sys/dev/iwn/if_iwnvar.h#7 integrate
.. //depot/projects/vap/sys/dev/mii/brgphy.c#7 integrate
.. //depot/projects/vap/sys/dev/mii/brgphyreg.h#5 integrate
.. //depot/projects/vap/sys/dev/mii/miidevs#9 integrate
.. //depot/projects/vap/sys/dev/usb/usbdevs#16 integrate
.. //depot/projects/vap/sys/dev/usb/uscanner.c#6 integrate
.. //depot/projects/vap/sys/i386/conf/NOTES#10 integrate
.. //depot/projects/vap/sys/kern/kern_thr.c#8 integrate
.. //depot/projects/vap/sys/kern/kern_umtx.c#8 integrate
.. //depot/projects/vap/sys/kern/uipc_mbuf.c#9 integrate
.. //depot/projects/vap/sys/kern/vfs_mount.c#14 integrate
.. //depot/projects/vap/sys/modules/Makefile#23 integrate
.. //depot/projects/vap/sys/modules/iwn/Makefile#2 integrate
.. //depot/projects/vap/sys/modules/iwnfw/Makefile#2 integrate
.. //depot/projects/vap/sys/net/bpf.c#14 integrate
.. //depot/projects/vap/sys/net/if_ethersubr.c#8 integrate
.. //depot/projects/vap/sys/netinet/ip_fw.h#8 integrate
.. //depot/projects/vap/sys/powerpc/aim/clock.c#4 integrate
.. //depot/projects/vap/sys/powerpc/aim/locore.S#6 integrate
.. //depot/projects/vap/sys/powerpc/aim/machdep.c#8 integrate
.. //depot/projects/vap/sys/powerpc/aim/mmu_oea.c#3 integrate
.. //depot/projects/vap/sys/powerpc/aim/mp_cpudep.c#1 branch
.. //depot/projects/vap/sys/powerpc/aim/swtch.S#3 integrate
.. //depot/projects/vap/sys/powerpc/aim/trap_subr.S#3 integrate
.. //depot/projects/vap/sys/powerpc/aim/vm_machdep.c#4 integrate
.. //depot/projects/vap/sys/powerpc/booke/trap_subr.S#2 integrate
.. //depot/projects/vap/sys/powerpc/conf/NOTES#7 integrate
.. //depot/projects/vap/sys/powerpc/include/cpufunc.h#4 integrate
.. //depot/projects/vap/sys/powerpc/include/pcpu.h#6 integrate
.. //depot/projects/vap/sys/powerpc/powerpc/intr_machdep.c#11 integrate
.. //depot/projects/vap/sys/powerpc/powerpc/mp_machdep.c#6 integrate
.. //depot/projects/vap/sys/powerpc/powerpc/openpic.c#7 integrate
.. //depot/projects/vap/sys/sys/mbuf.h#12 integrate
.. //depot/projects/vap/sys/sys/umtx.h#7 integrate
.. //depot/projects/vap/sys/sys/user.h#9 integrate
.. //depot/projects/vap/sys/vm/vm_kern.c#7 integrate
.. //depot/projects/vap/sys/vm/vm_map.c#9 integrate
.. //depot/projects/vap/sys/vm/vm_map.h#6 integrate
.. //depot/projects/vap/sys/vm/vm_mmap.c#9 integrate
.. //depot/projects/vap/usr.bin/fstat/Makefile#4 integrate
.. //depot/projects/vap/usr.bin/fstat/fstat.1#3 integrate
.. //depot/projects/vap/usr.bin/fstat/zfs/zfs.c#3 delete
.. //depot/projects/vap/usr.bin/stat/stat.1#3 integrate
.. //depot/projects/vap/usr.bin/talk/ctl.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/ctl_transact.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/display.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/get_addrs.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/get_iface.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/get_names.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/init_disp.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/invite.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/io.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/look_up.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/msgs.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/talk.c#3 integrate
.. //depot/projects/vap/usr.bin/talk/talk.h#3 integrate
Differences ...
==== //depot/projects/vap/Makefile#7 (text+ko) ====
@@ -1,5 +1,5 @@
#
-# $FreeBSD: src/Makefile,v 1.347 2008/03/31 13:32:55 pav Exp $
+# $FreeBSD: src/Makefile,v 1.348 2008/04/29 09:08:33 rwatson Exp $
#
# The user-driven targets are:
#
@@ -57,7 +57,7 @@
# 6. `mergemaster -p'
# 7. `make installworld'
# 8. `make delete-old'
-# 9. `mergemaster'
+# 9. `mergemaster' (you may wish to use -U or -ai).
# 10. `reboot'
# 11. `make delete-old-libs' (in case no 3rd party program uses them anymore)
#
==== //depot/projects/vap/UPDATING#10 (text+ko) ====
@@ -32,7 +32,9 @@
to
wlans_ath0=wlan0
ifconfig_wlan0="WPA DHCP"
- see rc.conf(5) for more details.
+ see rc.conf(5) for more details. In addition, mergemaster of
+ /etc/rc.d is highly recommended. Simultaneous update of userland
+ and kernel wouldn't hurt either.
As part of the multi-bss changes the wlan_scan_ap and wlan_scan_sta
modules were merged into the base wlan module. All references
@@ -1030,4 +1032,4 @@
Contact Warner Losh if you have any questions about your use of
this document.
-$FreeBSD: src/UPDATING,v 1.526 2008/04/27 04:07:36 imp Exp $
+$FreeBSD: src/UPDATING,v 1.527 2008/04/29 19:55:18 imp Exp $
==== //depot/projects/vap/bin/sh/expand.c#3 (text+ko) ====
@@ -36,7 +36,7 @@
#endif
#endif /* not lint */
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/sh/expand.c,v 1.51 2006/11/07 22:46:13 stefanf Exp $");
+__FBSDID("$FreeBSD: src/bin/sh/expand.c,v 1.52 2008/04/28 07:26:34 stefanf Exp $");
#include <sys/types.h>
#include <sys/time.h>
@@ -356,7 +356,7 @@
expari(int flag)
{
char *p, *start;
- int result;
+ arith_t result;
int begoff;
int quotes = flag & (EXP_FULL | EXP_CASE | EXP_REDIR);
int quoted;
@@ -372,10 +372,7 @@
* have to rescan starting from the beginning since CTLESC
* characters have to be processed left to right.
*/
-#if INT_MAX / 1000000000 >= 10 || INT_MIN / 1000000000 <= -10
-#error "integers with more than 10 digits are not supported"
-#endif
- CHECKSTRSPACE(12 - 2, expdest);
+ CHECKSTRSPACE(DIGITS(result) - 2, expdest);
USTPUTC('\0', expdest);
start = stackblock();
p = expdest - 2;
@@ -397,7 +394,7 @@
if (quotes)
rmescapes(p+2);
result = arith(p+2);
- fmtstr(p, 12, "%d", result);
+ fmtstr(p, DIGITS(result), ARITH_FORMAT_STR, result);
while (*p++)
;
if (quoted == 0)
==== //depot/projects/vap/games/fortune/datfiles/fortunes#8 (text+ko) ====
@@ -1,5 +1,5 @@
This fortune brought to you by:
-$FreeBSD: src/games/fortune/datfiles/fortunes,v 1.262 2008/04/26 22:15:03 yar Exp $
+$FreeBSD: src/games/fortune/datfiles/fortunes,v 1.263 2008/04/29 13:02:21 phk Exp $
%
=======================================================================
|| ||
@@ -13318,6 +13318,10 @@
Can anything be sadder than work left unfinished?
Yes, work never begun.
%
+"Can you be more stupid than aggravating the judge AND your lawyer?
+No? Oh yes you can: You can aggravate the whole kernel community."
+ -- Alexander Lyamin (about Hans Reisers murder trial)
+%
Can you buy friendship? You not only can, you must. It's the
only way to obtain friends. Everything worthwhile has a price.
-- Robert J. Ringer
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kgdb.h#6 (text+ko) ====
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/gnu/usr.bin/gdb/kgdb/kgdb.h,v 1.12 2008/02/25 22:04:07 jhb Exp $
+ * $FreeBSD: src/gnu/usr.bin/gdb/kgdb/kgdb.h,v 1.13 2008/04/29 20:32:45 jhb Exp $
*/
#ifndef _KGDB_H_
@@ -32,8 +32,6 @@
struct thread_info;
extern kvm_t *kvm;
-extern char *kernel;
-extern bfd *kern_bfd;
struct kthr {
struct kthr *next;
@@ -48,11 +46,14 @@
extern struct kthr *curkthr;
-void kgdb_add_kld_cmd(char *, int);
-void kgdb_kld_init(void);
-void kgdb_target(void);
+void initialize_kld_target(void);
+void initialize_kgdb_target(void);
+void kgdb_dmesg(void);
+void kgdb_trgt_new_objfile(struct objfile *);
void kgdb_trgt_fetch_registers(int);
void kgdb_trgt_store_registers(int);
+void kld_init(void);
+void kld_new_objfile(struct objfile *);
frame_unwind_sniffer_ftype kgdb_trgt_trapframe_sniffer;
@@ -67,6 +68,9 @@
char *kgdb_thr_extra_thread_info(int);
uintptr_t kgdb_lookup(const char *sym);
-CORE_ADDR kgdb_parse(const char *exp);
+CORE_ADDR kgdb_parse_1(const char *, int);
+
+#define kgdb_parse(exp) kgdb_parse_1((exp), 0)
+#define kgdb_parse_quiet(exp) kgdb_parse_1((exp), 1)
#endif /* _KGDB_H_ */
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kld.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kld.c,v 1.7 2008/03/29 03:48:06 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kld.c,v 1.9 2008/04/29 20:32:45 jhb Exp $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -55,6 +55,8 @@
/* KVA of 'linker_path' which corresponds to the kern.module_path sysctl .*/
static CORE_ADDR module_path_addr;
+static CORE_ADDR linker_files_addr;
+static CORE_ADDR kernel_file_addr;
static struct target_so_ops kld_so_ops;
@@ -70,7 +72,6 @@
/*
* Look for a matching file checking for debug suffixes before the raw file:
- * - filename + ".symbols" (e.g. foo.ko.symbols)
* - filename + ".debug" (e.g. foo.ko.debug)
* - filename (e.g. foo.ko)
*/
@@ -112,11 +113,14 @@
char *kernel_dir, *module_dir, *cp;
int error;
- kernel_dir = dirname(kernel);
- if (kernel_dir != NULL) {
- snprintf(path, path_size, "%s/%s", kernel_dir, filename);
- if (check_kld_path(path, path_size))
- return (1);
+ if (exec_bfd) {
+ kernel_dir = dirname(bfd_get_filename(exec_bfd));
+ if (kernel_dir != NULL) {
+ snprintf(path, path_size, "%s/%s", kernel_dir,
+ filename);
+ if (check_kld_path(path, path_size))
+ return (1);
+ }
}
if (module_path_addr != 0) {
target_read_string(module_path_addr, &module_path, PATH_MAX,
@@ -160,11 +164,12 @@
char *filename;
int error;
- if (off_address == 0 || off_filename == 0 || off_next == 0)
+ if (linker_files_addr == 0 || off_address == 0 || off_filename == 0 ||
+ off_next == 0)
return (0);
filename = basename(arg);
- for (kld = kgdb_parse("linker_files.tqh_first"); kld != 0;
+ for (kld = read_pointer(linker_files_addr); kld != 0;
kld = read_pointer(kld + off_next)) {
/* Try to read this linker file's filename. */
target_read_string(read_pointer(kld + off_filename),
@@ -195,7 +200,6 @@
struct section_addr_info *section_addrs;
int sect_index;
CORE_ADDR base_addr;
- int add_kld_command;
};
static void
@@ -215,14 +219,12 @@
asi->section_addrs->other[asi->sect_index].name = name;
asi->section_addrs->other[asi->sect_index].addr = address;
asi->section_addrs->other[asi->sect_index].sectindex = sect->index;
- if (asi->add_kld_command)
- printf_unfiltered("\t%s_addr = %s\n", name,
- local_hex_string(address));
+ printf_unfiltered("\t%s_addr = %s\n", name, local_hex_string(address));
asi->sect_index++;
}
static void
-load_kld (char *path, CORE_ADDR base_addr, int from_tty, int add_kld_command)
+load_kld (char *path, CORE_ADDR base_addr, int from_tty)
{
struct add_section_info asi;
struct cleanup *cleanup;
@@ -242,33 +244,32 @@
if (bfd_get_section_by_name (bfd, ".text") == NULL)
error("\"%s\": can't find text section", path);
- if (add_kld_command)
- printf_unfiltered("add symbol table from file \"%s\" at\n",
- path);
+ printf_unfiltered("add symbol table from file \"%s\" at\n", path);
/* Build a section table for symbol_file_add() from the bfd sections. */
asi.section_addrs = alloc_section_addr_info(bfd_count_sections(bfd));
cleanup = make_cleanup(xfree, asi.section_addrs);
asi.sect_index = 0;
asi.base_addr = base_addr;
- asi.add_kld_command = add_kld_command;
bfd_map_over_sections(bfd, add_section, &asi);
if (from_tty && (!query("%s", "")))
error("Not confirmed.");
- symbol_file_add(path, from_tty, asi.section_addrs, 0,
- add_kld_command ? OBJF_USERLOADED : 0);
+ symbol_file_add(path, from_tty, asi.section_addrs, 0, OBJF_USERLOADED);
do_cleanups(cleanup);
}
-void
+static void
kgdb_add_kld_cmd (char *arg, int from_tty)
{
char path[PATH_MAX];
CORE_ADDR base_addr;
+ if (!exec_bfd)
+ error("No kernel symbol file");
+
/* Try to open the raw path to handle absolute paths first. */
snprintf(path, sizeof(path), "%s", arg);
if (!check_kld_path(path, sizeof(path))) {
@@ -288,7 +289,7 @@
return;
}
- load_kld(path, base_addr, from_tty, 1);
+ load_kld(path, base_addr, from_tty);
reinit_frame_cache();
}
@@ -331,6 +332,10 @@
char *path;
int error;
+ if (linker_files_addr == 0 || kernel_file_addr == 0 ||
+ off_address == 0 || off_filename == 0 || off_next == 0)
+ return (NULL);
+
head = NULL;
prev = &head;
@@ -338,8 +343,8 @@
* Walk the list of linker files creating so_list entries for
* each non-kernel file.
*/
- kernel = kgdb_parse("linker_kernel_file");
- for (kld = kgdb_parse("linker_files.tqh_first"); kld != 0;
+ kernel = read_pointer(kernel_file_addr);
+ for (kld = read_pointer(linker_files_addr); kld != 0;
kld = read_pointer(kld + off_next)) {
/* Skip the main kernel file. */
if (kld == kernel)
@@ -436,6 +441,28 @@
return (fd);
}
+void
+kld_new_objfile (struct objfile *objfile)
+{
+
+ if (!have_partial_symbols())
+ return;
+
+ /*
+ * Compute offsets of relevant members in struct linker_file
+ * and the addresses of global variables. Don't warn about
+ * kernels that don't have 'pathname' in the linker_file
+ * struct since 6.x kernels don't have it.
+ */
+ off_address = kgdb_parse("&((struct linker_file *)0)->address");
+ off_filename = kgdb_parse("&((struct linker_file *)0)->filename");
+ off_pathname = kgdb_parse_quiet("&((struct linker_file *)0)->pathname");
+ off_next = kgdb_parse("&((struct linker_file *)0)->link.tqe_next");
+ module_path_addr = kgdb_parse("linker_path");
+ linker_files_addr = kgdb_parse("&linker_files.tqh_first");
+ kernel_file_addr = kgdb_parse("&linker_kernel_file");
+}
+
static int
load_klds_stub (void *arg)
{
@@ -445,19 +472,16 @@
}
void
-kgdb_kld_init (void)
+kld_init (void)
{
- struct cmd_list_element *c;
- /* Compute offsets of relevant members in struct linker_file. */
- off_address = kgdb_parse("&((struct linker_file *)0)->address");
- off_filename = kgdb_parse("&((struct linker_file *)0)->filename");
- off_pathname = kgdb_parse("&((struct linker_file *)0)->pathname");
- off_next = kgdb_parse("&((struct linker_file *)0)->link.tqe_next");
- if (off_address == 0 || off_filename == 0 || off_next == 0)
- return;
+ catch_errors(load_klds_stub, NULL, NULL, RETURN_MASK_ALL);
+}
- module_path_addr = kgdb_parse("linker_path");
+void
+initialize_kld_target(void)
+{
+ struct cmd_list_element *c;
kld_so_ops.relocate_section_addresses = kld_relocate_section_addresses;
kld_so_ops.free_so = kld_free_so;
@@ -471,8 +495,6 @@
current_target_so_ops = &kld_so_ops;
- catch_errors(load_klds_stub, NULL, NULL, RETURN_MASK_ALL);
-
c = add_com("add-kld", class_files, kgdb_add_kld_cmd,
"Usage: add-kld FILE\n\
Load the symbols from the kernel loadable module FILE.");
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kthr.c#5 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.10 2008/01/28 20:33:19 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.11 2008/04/29 20:32:45 jhb Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -78,6 +78,12 @@
struct thread td;
struct kthr *kt;
uintptr_t addr, paddr;
+
+ while (first != NULL) {
+ kt = first;
+ first = kt->next;
+ free(kt);
+ }
addr = kgdb_lookup("_allproc");
if (addr == 0) {
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/main.c#6 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/main.c,v 1.15 2008/03/29 17:46:03 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/main.c,v 1.16 2008/04/29 20:32:45 jhb Exp $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -37,7 +37,6 @@
#include <sys/wait.h>
#include <errno.h>
#include <err.h>
-#include <fcntl.h>
#include <inttypes.h>
#include <kvm.h>
#include <limits.h>
@@ -55,42 +54,31 @@
#include <interps.h>
#include <cli-out.h>
#include <main.h>
+#include <objfiles.h>
#include <target.h>
#include <top.h>
+#include <ui-file.h>
#include <bfd.h>
#include <gdbcore.h>
#include <wrapper.h>
-extern void (*init_ui_hook)(char *);
-
extern frame_unwind_sniffer_ftype *kgdb_sniffer_kluge;
-extern void symbol_file_add_main (char *args, int from_tty);
-
#include "kgdb.h"
-kvm_t *kvm;
-static char kvm_err[_POSIX2_LINE_MAX];
-
static int dumpnr;
static int quiet;
static int verbose;
static char crashdir[PATH_MAX];
-char *kernel;
+static char *kernel;
static char *remote;
static char *vmcore;
+static struct ui_file *parse_gdberr;
static void (*kgdb_new_objfile_chain)(struct objfile * objfile);
static void
-kgdb_atexit(void)
-{
- if (kvm != NULL)
- kvm_close(kvm);
-}
-
-static void
usage(void)
{
@@ -168,27 +156,42 @@
static void
kgdb_new_objfile(struct objfile *objfile)
{
-#if 0
- printf("XXX: %s(%p)\n", __func__, objfile);
- if (objfile != NULL) {
- goto out;
- }
+ static int once = 1;
+
+ kld_new_objfile(objfile);
+ kgdb_trgt_new_objfile(objfile);
-out:
-#endif
if (kgdb_new_objfile_chain != NULL)
kgdb_new_objfile_chain(objfile);
+
+ if (once && objfile != NULL && objfile == symfile_objfile) {
+ /*
+ * The initial kernel has just been loaded. Start the
+ * remote target if we have one.
+ */
+ once = 0;
+ if (remote != NULL)
+ push_remote_target (remote, 0);
+ }
}
+/*
+ * Parse an expression and return its value. If 'quiet' is true, then
+ * any error messages from the parser are masked.
+ */
CORE_ADDR
-kgdb_parse(const char *exp)
+kgdb_parse_1(const char *exp, int quiet)
{
+ struct ui_file *old_stderr;
struct cleanup *old_chain;
struct expression *expr;
struct value *val;
char *s;
CORE_ADDR n;
+ old_stderr = gdb_stderr;
+ if (quiet)
+ gdb_stderr = parse_gdberr;
n = 0;
s = xstrdup(exp);
old_chain = make_cleanup(xfree, s);
@@ -198,45 +201,19 @@
n = value_as_address(val);
}
do_cleanups(old_chain);
+ gdb_stderr = old_stderr;
return (n);
}
#define MSGBUF_SEQ_TO_POS(size, seq) ((seq) % (size))
-static void
-kgdb_init_target(void)
+void
+kgdb_dmesg(void)
{
CORE_ADDR bufp;
int size, rseq, wseq;
- int kern_desc;
char c;
- kern_desc = open(kernel, O_RDONLY);
- if (kern_desc == -1)
- errx(1, "couldn't open a kernel image");
-
- kern_bfd = bfd_fdopenr(kernel, gnutarget, kern_desc);
- if (kern_bfd == NULL) {
- close(kern_desc);
- errx(1, "\"%s\": can't open to probe ABI: %s.", kernel,
- bfd_errmsg (bfd_get_error ()));
- }
- bfd_set_cacheable(kern_bfd, 1);
-
- if (!bfd_check_format (kern_bfd, bfd_object)) {
- bfd_close(kern_bfd);
- errx(1, "\"%s\": not in executable format: %s", kernel,
- bfd_errmsg(bfd_get_error()));
- }
-
- set_gdbarch_from_file (kern_bfd);
-
- symbol_file_add_main (kernel, 0);
- if (remote)
- push_remote_target (remote, 0);
- else
- kgdb_target();
-
/*
* Display the unread portion of the message buffer. This gives the
* user a some initial data to work from.
@@ -266,37 +243,54 @@
}
static void
-kgdb_interp_command_loop(void *data)
+kgdb_init(char *argv0 __unused)
+{
+
+ parse_gdberr = mem_fileopen();
+ set_prompt("(kgdb) ");
+ initialize_kgdb_target();
+ initialize_kld_target();
+ kgdb_new_objfile_chain = target_new_objfile_hook;
+ target_new_objfile_hook = kgdb_new_objfile;
+}
+
+/*
+ * Remote targets can support any number of syntaxes and we want to
+ * support them all with one addition: we support specifying a device
+ * node for a serial device without the "/dev/" prefix.
+ *
+ * What we do is to stat(2) the existing remote target first. If that
+ * fails, we try it with "/dev/" prepended. If that succeeds we use
+ * the resulting path, otherwise we use the original target. If
+ * either stat(2) succeeds make sure the file is either a character
+ * device or a FIFO.
+ */
+static void
+verify_remote(void)
{
- static int once = 0;
+ char path[PATH_MAX];
+ struct stat st;
- if (!once) {
- once = 1;
- kgdb_init_target();
- print_stack_frame(get_selected_frame(),
- frame_relative_level(get_selected_frame()), 1);
+ if (stat(remote, &st) != 0) {
+ snprintf(path, sizeof(path), "/dev/%s", remote);
+ if (stat(path, &st) != 0)
+ return;
+ free(remote);
+ remote = strdup(path);
}
- command_loop();
+ if (!S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode))
+ errx(1, "%s: not a special file, FIFO or socket", remote);
}
static void
-kgdb_init(char *argv0 __unused)
+add_arg(struct captured_main_args *args, char *arg)
{
- static struct interp_procs procs = {
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- kgdb_interp_command_loop
- };
- struct interp *kgdb;
- kgdb = interp_new("kgdb", NULL, cli_out_new(gdb_stdout), &procs);
- interp_add(kgdb);
- set_prompt("(kgdb) ");
- kgdb_new_objfile_chain = target_new_objfile_hook;
- target_new_objfile_hook = kgdb_new_objfile;
+ args->argc++;
+ args->argv = reallocf(args->argv, (args->argc + 1) * sizeof(char *));
+ if (args->argv == NULL)
+ err(1, "Out of memory building argument list");
+ args->argv[args->argc] = arg;
}
int
@@ -306,7 +300,7 @@
struct stat st;
struct captured_main_args args;
char *s;
- int a, ch, writecore;
+ int a, ch;
dumpnr = -1;
@@ -331,7 +325,11 @@
}
quiet = 0;
- writecore = 0;
+ memset (&args, 0, sizeof args);
+ args.use_windows = 0;
+ args.interpreter_p = INTERP_CONSOLE;
+ args.argv = malloc(sizeof(char *));
+ args.argv[0] = argv[0];
while ((ch = getopt(argc, argv, "ac:d:fn:qr:vw")) != -1) {
switch (ch) {
@@ -364,6 +362,7 @@
break;
case 'q':
quiet = 1;
+ add_arg(&args, "-q");
break;
case 'r': /* use given device for remote session. */
if (remote != NULL) {
@@ -378,7 +377,7 @@
verbose++;
break;
case 'w': /* core file is writeable. */
- writecore = 1;
+ add_arg(&args, "--write");
break;
case '?':
default:
@@ -411,21 +410,8 @@
if (!S_ISREG(st.st_mode))
errx(1, "%s: not a regular file", path);
vmcore = strdup(path);
- } else if (remote != NULL && remote[0] != ':' && remote[0] != '|') {
- if (stat(remote, &st) != 0) {
- snprintf(path, sizeof(path), "/dev/%s", remote);
- if (stat(path, &st) != 0) {
- err(1, "%s", remote);
- /* NOTREACHED */
- }
- free(remote);
- remote = strdup(path);
- }
- if (!S_ISCHR(st.st_mode) && !S_ISFIFO(st.st_mode)) {
- errx(1, "%s: not a special file, FIFO or socket",
- remote);
- /* NOTREACHED */
- }
+ } else if (remote != NULL) {
+ verify_remote();
} else if (argc > optind) {
if (vmcore == NULL)
vmcore = strdup(argv[optind++]);
@@ -445,20 +431,12 @@
warnx("kernel image: %s", kernel);
}
- /*
- * At this point we must either have a core file or have a kernel
- * with a remote target.
- */
+ /* A remote target requires an explicit kernel argument. */
if (remote != NULL && kernel == NULL) {
warnx("remote debugging requires a kernel");
usage();
/* NOTREACHED */
}
- if (vmcore == NULL && remote == NULL) {
- warnx("need a core file or a device for remote debugging");
- usage();
- /* NOTREACHED */
- }
/* If we don't have a kernel image yet, try to find one. */
if (kernel == NULL) {
@@ -470,27 +448,16 @@
if (verbose)
warnx("kernel image: %s", kernel);
}
+ add_arg(&args, kernel);
- if (remote == NULL) {
- kvm = kvm_openfiles(kernel, vmcore, NULL,
- writecore ? O_RDWR : O_RDONLY, kvm_err);
- if (kvm == NULL)
- errx(1, kvm_err);
- atexit(kgdb_atexit);
- kgdb_thr_init();
- }
+ if (vmcore != NULL)
+ add_arg(&args, vmcore);
/* The libgdb code uses optind too. Reset it... */
optind = 0;
- memset (&args, 0, sizeof args);
- args.argv = argv;
- args.argc = 1 + quiet;
- if (quiet)
- argv[1] = "-q";
- argv[args.argc] = NULL;
- args.use_windows = 0;
- args.interpreter_p = "kgdb";
+ /* Terminate argv list. */
+ add_arg(&args, NULL);
init_ui_hook = kgdb_init;
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt.c#5 (text+ko) ====
@@ -25,29 +25,39 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.10 2008/01/29 23:44:34 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.11 2008/04/29 20:32:45 jhb Exp $");
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <err.h>
+#include <fcntl.h>
#include <kvm.h>
#include <defs.h>
+#include <readline/readline.h>
+#include <readline/tilde.h>
#include <command.h>
#include <exec.h>
#include <frame-unwind.h>
+#include <gdbcore.h>
#include <gdbthread.h>
#include <inferior.h>
+#include <language.h>
#include <regcache.h>
+#include <solib.h>
#include <target.h>
#include "kgdb.h"
+static void kgdb_core_cleanup(void *);
+
+static char *vmcore;
static struct target_ops kgdb_trgt_ops;
-bfd *kern_bfd;
+kvm_t *kvm;
+static char kvm_err[_POSIX2_LINE_MAX];
#define KERNOFF (kgdb_kernbase ())
#define INKERNEL(x) ((x) >= KERNOFF)
@@ -69,6 +79,111 @@
return kernbase;
}
+static void
+kgdb_trgt_open(char *filename, int from_tty)
+{
+ struct cleanup *old_chain;
+ struct thread_info *ti;
+ struct kthr *kt;
+ kvm_t *nkvm;
+ char *temp;
+ int ontop;
+
+ target_preopen (from_tty);
+ if (!filename)
+ error ("No vmcore file specified.");
+ if (!exec_bfd)
+ error ("Can't open a vmcore without a kernel");
+
+ filename = tilde_expand (filename);
+ if (filename[0] != '/') {
+ temp = concat (current_directory, "/", filename, NULL);
+ xfree(filename);
+ filename = temp;
+ }
+
+ old_chain = make_cleanup (xfree, filename);
+
+ nkvm = kvm_openfiles(bfd_get_filename(exec_bfd), filename, NULL,
+ write_files ? O_RDWR : O_RDONLY, kvm_err);
+ if (nkvm == NULL)
+ error ("Failed to open vmcore: %s", kvm_err);
+
+ /* Don't free the filename now and close any previous vmcore. */
+ discard_cleanups(old_chain);
+ unpush_target(&kgdb_trgt_ops);
+
+ kvm = nkvm;
+ vmcore = filename;
+ old_chain = make_cleanup(kgdb_core_cleanup, NULL);
+
+ ontop = !push_target (&kgdb_trgt_ops);
+ discard_cleanups (old_chain);
+
+ kgdb_dmesg();
+
+ init_thread_list();
+ kt = kgdb_thr_init();
+ while (kt != NULL) {
+ ti = add_thread(ptid_build(kt->pid, 0, kt->tid));
+ kt = kgdb_thr_next(kt);
+ }
+ if (curkthr != 0)
+ inferior_ptid = ptid_build(curkthr->pid, 0, curkthr->tid);
+
+ if (ontop) {
+ /* XXX: fetch registers? */
+ kld_init();
+ flush_cached_frames();
+ select_frame (get_current_frame());
+ print_stack_frame(get_selected_frame(),
+ frame_relative_level(get_selected_frame()), 1);
+ } else
+ warning(
+ "you won't be able to access this vmcore until you terminate\n\
+your %s; do ``info files''", target_longname);
+}
+
+static void
+kgdb_trgt_close(int quitting)
+{
+
+ if (kvm != NULL) {
+ inferior_ptid = null_ptid;
+ CLEAR_SOLIB();
+ if (kvm_close(kvm) != 0)
+ warning("cannot close \"%s\": %s", vmcore,
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list