PERFORCE change 134613 for review
Sam Leffler
sam at FreeBSD.org
Fri Feb 1 16:43:19 PST 2008
http://perforce.freebsd.org/chv.cgi?CH=134613
Change 134613 by sam at sam_ebb on 2008/02/02 00:42:40
IFC @ 134612
Affected files ...
.. //depot/projects/vap/Makefile#4 integrate
.. //depot/projects/vap/contrib/binutils/libiberty/cp-demangle.c#3 integrate
.. //depot/projects/vap/contrib/file/FREEBSD-upgrade#3 integrate
.. //depot/projects/vap/contrib/libiberty/cp-demangle.c#2 delete
.. //depot/projects/vap/contrib/openpam/include/security/openpam_version.h#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kgdb.h#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kld.c#2 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kthr.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/main.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt.c#4 integrate
.. //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt_i386.c#3 integrate
.. //depot/projects/vap/lib/libarchive/archive_read_support_format_tar.c#4 integrate
.. //depot/projects/vap/lib/libarchive/archive_write_set_format_ar.c#4 integrate
.. //depot/projects/vap/lib/libarchive/test/Makefile#5 integrate
.. //depot/projects/vap/lib/libarchive/test/test_compat_tar_hardlink.c#1 branch
.. //depot/projects/vap/lib/libarchive/test/test_compat_tar_hardlink_1.tar.uu#1 branch
.. //depot/projects/vap/lib/libc/sys/extattr_get_file.2#3 integrate
.. //depot/projects/vap/lib/libdevstat/devstat.h#3 integrate
.. //depot/projects/vap/lib/libkse/sys/lock.c#3 integrate
.. //depot/projects/vap/lib/msun/src/s_exp2f.c#4 integrate
.. //depot/projects/vap/sbin/ffsinfo/ffsinfo.c#3 integrate
.. //depot/projects/vap/sbin/fsck_msdosfs/boot.c#4 integrate
.. //depot/projects/vap/sbin/fsck_msdosfs/fat.c#3 integrate
.. //depot/projects/vap/sbin/gpt/gpt.c#3 integrate
.. //depot/projects/vap/share/man/man4/ath.4#3 integrate
.. //depot/projects/vap/share/man/man4/atkbd.4#3 integrate
.. //depot/projects/vap/share/man/man4/awi.4#3 integrate
.. //depot/projects/vap/share/man/man4/ed.4#5 integrate
.. //depot/projects/vap/share/man/man4/man4.i386/snc.4#3 integrate
.. //depot/projects/vap/share/man/man4/wi.4#3 integrate
.. //depot/projects/vap/share/man/man9/mbuf.9#3 integrate
.. //depot/projects/vap/share/msgdef/Makefile#3 integrate
.. //depot/projects/vap/share/msgdef/ko_KR.UTF-8.src#1 branch
.. //depot/projects/vap/share/msgdef/ko_KR.eucKR.src#3 integrate
.. //depot/projects/vap/sys/amd64/acpica/madt.c#6 integrate
.. //depot/projects/vap/sys/amd64/amd64/dump_machdep.c#5 integrate
.. //depot/projects/vap/sys/amd64/amd64/minidump_machdep.c#3 integrate
.. //depot/projects/vap/sys/amd64/include/proc.h#4 integrate
.. //depot/projects/vap/sys/arm/arm/dump_machdep.c#5 integrate
.. //depot/projects/vap/sys/arm/arm/pmap.c#8 integrate
.. //depot/projects/vap/sys/arm/include/pmap.h#6 integrate
.. //depot/projects/vap/sys/cam/cam_xpt.c#7 integrate
.. //depot/projects/vap/sys/compat/ndis/kern_ndis.c#6 integrate
.. //depot/projects/vap/sys/conf/files.powerpc#7 integrate
.. //depot/projects/vap/sys/ddb/db_textdump.c#2 integrate
.. //depot/projects/vap/sys/dev/acpica/acpi.c#7 integrate
.. //depot/projects/vap/sys/dev/bfe/if_bfe.c#6 integrate
.. //depot/projects/vap/sys/dev/bfe/if_bfereg.h#5 integrate
.. //depot/projects/vap/sys/dev/ciss/ciss.c#6 integrate
.. //depot/projects/vap/sys/dev/cxgb/cxgb_sge.c#5 integrate
.. //depot/projects/vap/sys/dev/cxgb/ulp/tom/cxgb_cpl_socket.c#2 integrate
.. //depot/projects/vap/sys/dev/hatm/if_hatm_intr.c#5 integrate
.. //depot/projects/vap/sys/dev/iscsi/initiator/isc_soc.c#3 integrate
.. //depot/projects/vap/sys/dev/lge/if_lge.c#6 integrate
.. //depot/projects/vap/sys/dev/msk/if_msk.c#5 integrate
.. //depot/projects/vap/sys/dev/mxge/if_mxge.c#4 integrate
.. //depot/projects/vap/sys/dev/nfe/if_nfe.c#4 integrate
.. //depot/projects/vap/sys/dev/patm/if_patm_rx.c#5 integrate
.. //depot/projects/vap/sys/dev/pci/pci.c#6 integrate
.. //depot/projects/vap/sys/dev/sk/if_sk.c#3 integrate
.. //depot/projects/vap/sys/dev/ti/if_ti.c#3 integrate
.. //depot/projects/vap/sys/dev/wpi/if_wpi.c#6 integrate
.. //depot/projects/vap/sys/i386/acpica/madt.c#6 integrate
.. //depot/projects/vap/sys/i386/i386/dump_machdep.c#5 integrate
.. //depot/projects/vap/sys/i386/i386/minidump_machdep.c#3 integrate
.. //depot/projects/vap/sys/i386/include/proc.h#6 integrate
.. //depot/projects/vap/sys/ia64/ia64/dump_machdep.c#5 integrate
.. //depot/projects/vap/sys/kern/kern_mbuf.c#7 integrate
.. //depot/projects/vap/sys/kern/kern_shutdown.c#8 integrate
.. //depot/projects/vap/sys/kern/uipc_cow.c#5 integrate
.. //depot/projects/vap/sys/kern/uipc_mbuf.c#7 integrate
.. //depot/projects/vap/sys/kern/uipc_sockbuf.c#4 integrate
.. //depot/projects/vap/sys/kern/uipc_socket.c#6 integrate
.. //depot/projects/vap/sys/kern/uipc_syscalls.c#7 integrate
.. //depot/projects/vap/sys/kern/vfs_aio.c#8 integrate
.. //depot/projects/vap/sys/net80211/ieee80211_ht.c#7 integrate
.. //depot/projects/vap/sys/netgraph/netgraph.h#6 integrate
.. //depot/projects/vap/sys/netgraph/ng_base.c#7 integrate
.. //depot/projects/vap/sys/netgraph/ng_bpf.c#5 integrate
.. //depot/projects/vap/sys/netgraph/ng_iface.c#6 integrate
.. //depot/projects/vap/sys/netgraph/ng_pppoe.c#7 integrate
.. //depot/projects/vap/sys/netinet/sctp_auth.c#3 integrate
.. //depot/projects/vap/sys/netinet/sctp_bsd_addr.c#4 integrate
.. //depot/projects/vap/sys/netinet/sctp_indata.c#3 integrate
.. //depot/projects/vap/sys/netinet/sctp_input.c#3 integrate
.. //depot/projects/vap/sys/netinet/sctp_pcb.c#3 integrate
.. //depot/projects/vap/sys/netinet/sctp_peeloff.c#3 integrate
.. //depot/projects/vap/sys/netinet/sctputil.c#4 integrate
.. //depot/projects/vap/sys/pci/if_wb.c#6 integrate
.. //depot/projects/vap/sys/security/audit/audit.c#4 integrate
.. //depot/projects/vap/sys/security/mac_mls/mac_mls.c#6 integrate
.. //depot/projects/vap/sys/sparc64/sparc64/dump_machdep.c#3 integrate
.. //depot/projects/vap/sys/sun4v/sun4v/dump_machdep.c#3 integrate
.. //depot/projects/vap/sys/sys/conf.h#6 integrate
.. //depot/projects/vap/sys/sys/mbuf.h#8 integrate
.. //depot/projects/vap/sys/sys/param.h#8 integrate
.. //depot/projects/vap/sys/sys/proc.h#7 integrate
.. //depot/projects/vap/sys/sys/socketvar.h#7 integrate
.. //depot/projects/vap/tools/regression/sockets/unix_sorflush/Makefile#1 branch
.. //depot/projects/vap/tools/regression/sockets/unix_sorflush/unix_sorflush.c#1 branch
.. //depot/projects/vap/usr.bin/file/Makefile#3 integrate
.. //depot/projects/vap/usr.bin/file/file.1#3 delete
.. //depot/projects/vap/usr.bin/file/magic.5#3 delete
.. //depot/projects/vap/usr.bin/top/machine.c#5 integrate
.. //depot/projects/vap/usr.sbin/Makefile#4 integrate
.. //depot/projects/vap/usr.sbin/bootparamd/bootparamd/bootparamd.c#3 integrate
.. //depot/projects/vap/usr.sbin/bootparamd/bootparamd/main.c#3 integrate
.. //depot/projects/vap/usr.sbin/kbdcontrol/kbdcontrol.1#3 integrate
.. //depot/projects/vap/usr.sbin/kbdcontrol/kbdmap.5#3 integrate
.. //depot/projects/vap/usr.sbin/newsyslog/newsyslog.c#3 integrate
.. //depot/projects/vap/usr.sbin/ofwdump/Makefile#3 integrate
.. //depot/projects/vap/usr.sbin/ofwdump/ofwdump.8#3 integrate
.. //depot/projects/vap/usr.sbin/setfmac/setfmac.c#4 integrate
.. //depot/projects/vap/usr.sbin/sysinstall/disks.c#3 integrate
.. //depot/projects/vap/usr.sbin/watch/watch.c#3 integrate
Differences ...
==== //depot/projects/vap/Makefile#4 (text+ko) ====
@@ -1,5 +1,5 @@
#
-# $FreeBSD: src/Makefile,v 1.344 2007/12/13 00:08:02 imp Exp $
+# $FreeBSD: src/Makefile,v 1.345 2008/01/30 19:33:18 jhb Exp $
#
# The user-driven targets are:
#
@@ -75,6 +75,8 @@
# developer convenience only. They are intentionally not documented and
# completely subject to change without notice.
#
+# For more information, see the build(7) manual page.
+#
TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
check-old check-old-dirs check-old-files check-old-libs \
checkdpadd clean cleandepend cleandir \
==== //depot/projects/vap/contrib/binutils/libiberty/cp-demangle.c#3 (text+ko) ====
@@ -2396,6 +2396,8 @@
const char *s;
type = cplus_demangle_type (di);
+ if (type == NULL)
+ return NULL;
/* If we have a type we know how to print, we aren't going to
print the type name itself. */
==== //depot/projects/vap/contrib/file/FREEBSD-upgrade#3 (text+ko) ====
@@ -1,5 +1,5 @@
# ex:ts=8
-$FreeBSD: src/contrib/file/FREEBSD-upgrade,v 1.7 2007/05/24 22:02:49 obrien Exp $
+$FreeBSD: src/contrib/file/FREEBSD-upgrade,v 1.8 2008/01/30 02:48:24 obrien Exp $
Christos Zoulas `file'
originals can be found at: ftp://ftp.astron.com/pub/file/
@@ -17,14 +17,14 @@
rm -f missing depcomp
rm -f config.{guess,sub}
- cvs import -m "Virgin import of Christos Zoulas's FILE 4.21." \
- src/contrib/file ZOULAS file_4_21
+ cvs import -m "Virgin import of Christos Zoulas's FILE 4.23." \
+ src/contrib/file ZOULAS file_4_23
Never make local changes to ZOULAS `file'. Christos is very willing to
work with us to meet our FreeBSD needs. Thus submit any desired changes
to him <christos at zoulas.com> and wait for the next release and vendor
import to get them.
-
+
obrien at NUXI.com
15-Sept-2002
==== //depot/projects/vap/contrib/openpam/include/security/openpam_version.h#4 (text) ====
@@ -32,7 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: openpam_version.h 409 2007-12-21 11:38:50Z des $
+ * $Id: openpam_version.h 412 2008-01-29 19:31:46Z des $
*/
#ifndef SECURITY_OPENPAM_VERSION_H_INCLUDED
@@ -42,4 +42,7 @@
#define OPENPAM_VERSION 20071221
#define OPENPAM_RELEASE "Hydrangea"
+/* violates reserved namespace, but can't be removed for legacy reasons */
+#define _OPENPAM
+
#endif /* !SECURITY_OPENPAM_VERSION_H_INCLUDED */
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kgdb.h#4 (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.8 2008/01/24 19:11:13 jhb Exp $
+ * $FreeBSD: src/gnu/usr.bin/gdb/kgdb/kgdb.h,v 1.11 2008/01/29 23:44:34 jhb Exp $
*/
#ifndef _KGDB_H_
@@ -33,6 +33,7 @@
extern kvm_t *kvm;
extern char *kernel;
+extern bfd *kern_bfd;
struct kthr {
struct kthr *next;
@@ -48,6 +49,8 @@
extern struct kthr *curkthr;
void kgdb_add_kld_cmd(char *, int);
+void kgdb_auto_load_klds(void);
+void kgdb_kld_init(void);
void kgdb_target(void);
void kgdb_trgt_fetch_registers(int);
void kgdb_trgt_store_registers(int);
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kld.c#2 (text+ko) ====
@@ -25,22 +25,39 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kld.c,v 1.1 2008/01/24 19:11:13 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kld.c,v 1.6 2008/01/29 23:44:34 jhb Exp $");
#include <sys/param.h>
#include <sys/stat.h>
+#include <fcntl.h>
+#include <kvm.h>
#include <libgen.h>
-#include <kvm.h>
#include <defs.h>
+#include <command.h>
+#include <completer.h>
+#include <environ.h>
#include <frame-unwind.h>
#include <inferior.h>
#include <objfiles.h>
#include <gdbcore.h>
#include <language.h>
+#include <solist.h>
#include "kgdb.h"
+struct lm_info {
+ CORE_ADDR base_address;
+};
+
+/* Offsets of fields in linker_file structure. */
+static CORE_ADDR off_address, off_filename, off_pathname, off_next;
+
+/* KVA of 'linker_path' which corresponds to the kern.module_path sysctl .*/
+static CORE_ADDR module_path_addr;
+
+static struct target_so_ops kld_so_ops;
+
static int
kld_ok (char *path)
{
@@ -52,68 +69,69 @@
}
/*
- * Look for a matching file in the following order:
+ * 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)
- * - dirname(kernel) + filename + ".symbols" (e.g. /boot/kernel/foo.ko.symbols)
- * - dirname(kernel) + filename + ".debug" (e.g. /boot/kernel/foo.ko.debug)
- * - dirname(kernel) + filename (e.g. /boot/kernel/foo.ko)
- * - iterate over each path in the module path looking for:
- * - dir + filename + ".symbols" (e.g. /boot/modules/foo.ko.symbols)
- * - dir + filename + ".debug" (e.g. /boot/modules/foo.ko.debug)
- * - dir + filename (e.g. /boot/modules/foo.ko)
+ */
+static const char *kld_suffixes[] = {
+ ".debug",
+ "",
+ NULL
+};
+
+static int
+check_kld_path (char *path, size_t path_size)
+{
+ const char **suffix;
+ char *ep;
+
+ ep = path + strlen(path);
+ suffix = kld_suffixes;
+ while (*suffix != NULL) {
+ if (strlcat(path, *suffix, path_size) < path_size) {
+ if (kld_ok(path))
+ return (1);
+ }
+
+ /* Restore original path to remove suffix. */
+ *ep = '\0';
+ suffix++;
+ }
+ return (0);
+}
+
+/*
+ * Try to find the path for a kld by looking in the kernel's directory and
+ * in the various paths in the module path.
*/
static int
find_kld_path (char *filename, char *path, size_t path_size)
{
- CORE_ADDR module_path_addr;
- char module_path[PATH_MAX];
+ char *module_path;
char *kernel_dir, *module_dir, *cp;
+ int error;
- snprintf(path, path_size, "%s.symbols", filename);
- if (kld_ok(path))
- return (1);
- snprintf(path, path_size, "%s.debug", filename);
- if (kld_ok(path))
- return (1);
- snprintf(path, path_size, "%s", filename);
- if (kld_ok(path))
- return (1);
kernel_dir = dirname(kernel);
if (kernel_dir != NULL) {
- snprintf(path, path_size, "%s/%s.symbols", kernel_dir,
- filename);
- if (kld_ok(path))
- return (1);
- snprintf(path, path_size, "%s/%s.debug", kernel_dir, filename);
- if (kld_ok(path))
- return (1);
snprintf(path, path_size, "%s/%s", kernel_dir, filename);
- if (kld_ok(path))
+ if (check_kld_path(path, path_size))
return (1);
}
- module_path_addr = kgdb_parse("linker_path");
- if (module_path_addr != 0 &&
- kvm_read(kvm, module_path_addr, module_path, sizeof(module_path)) ==
- sizeof(module_path)) {
- module_path[PATH_MAX - 1] = '\0';
- cp = module_path;
- while ((module_dir = strsep(&cp, ";")) != NULL) {
- snprintf(path, path_size, "%s/%s.symbols", module_dir,
- filename);
- if (kld_ok(path))
- return (1);
- snprintf(path, path_size, "%s/%s.debug", module_dir,
- filename);
- if (kld_ok(path))
- return (1);
- snprintf(path, path_size, "%s/%s", module_dir,
- filename);
- if (kld_ok(path))
- return (1);
+ if (module_path_addr != 0) {
+ target_read_string(module_path_addr, &module_path, PATH_MAX,
+ &error);
+ if (error == 0) {
+ make_cleanup(xfree, module_path);
+ cp = module_path;
+ while ((module_dir = strsep(&cp, ";")) != NULL) {
+ snprintf(path, path_size, "%s/%s", module_dir,
+ filename);
+ if (check_kld_path(path, path_size))
+ return (1);
+ }
}
- }
+ }
return (0);
}
@@ -123,25 +141,12 @@
static CORE_ADDR
read_pointer (CORE_ADDR address)
{
- union {
- uint32_t d32;
- uint64_t d64;
- } val;
+ CORE_ADDR value;
- switch (TARGET_PTR_BIT) {
- case 32:
- if (kvm_read(kvm, address, &val.d32, sizeof(val.d32)) !=
- sizeof(val.d32))
- return (0);
- return (val.d32);
- case 64:
- if (kvm_read(kvm, address, &val.d64, sizeof(val.d64)) !=
- sizeof(val.d64))
- return (0);
- return (val.d64);
- default:
- return (0);
- }
+ if (target_read_memory(address, (char *)&value, TARGET_PTR_BIT / 8) !=
+ 0)
+ return (0);
+ return (extract_unsigned_integer(&value, TARGET_PTR_BIT / 8));
}
/*
@@ -150,36 +155,29 @@
static int
find_kld_address (char *arg, CORE_ADDR *address)
{
- CORE_ADDR kld, filename_addr;
- CORE_ADDR off_address, off_filename, off_next;
- char kld_filename[PATH_MAX];
+ CORE_ADDR kld;
+ char *kld_filename;
char *filename;
- size_t filelen;
+ int error;
- /* 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_next = kgdb_parse("&((struct linker_file *)0)->link.tqe_next");
if (off_address == 0 || off_filename == 0 || off_next == 0)
return (0);
filename = basename(arg);
- filelen = strlen(filename) + 1;
- kld = kgdb_parse("linker_files.tqh_first");
- while (kld != 0) {
+ for (kld = kgdb_parse("linker_files.tqh_first"); kld != 0;
+ kld = read_pointer(kld + off_next)) {
/* Try to read this linker file's filename. */
- filename_addr = read_pointer(kld + off_filename);
- if (filename_addr == 0)
- goto next_kld;
- if (kvm_read(kvm, filename_addr, kld_filename, filelen) !=
- filelen)
- goto next_kld;
+ target_read_string(read_pointer(kld + off_filename),
+ &kld_filename, PATH_MAX, &error);
+ if (error)
+ continue;
/* Compare this kld's filename against our passed in name. */
- if (kld_filename[filelen - 1] != '\0')
- goto next_kld;
- if (strcmp(kld_filename, filename) != 0)
- goto next_kld;
+ if (strcmp(kld_filename, filename) != 0) {
+ xfree(kld_filename);
+ continue;
+ }
+ xfree(kld_filename);
/*
* We found a match, use its address as the base
@@ -189,116 +187,293 @@
if (*address == 0)
return (0);
return (1);
-
- next_kld:
- kld = read_pointer(kld + off_next);
}
return (0);
}
+struct add_section_info {
+ struct section_addr_info *section_addrs;
+ int sect_index;
+ CORE_ADDR base_addr;
+ int add_kld_command;
+};
+
static void
-add_section(struct section_addr_info *section_addrs, int *sect_indexp,
- char *name, CORE_ADDR address)
+add_section (bfd *bfd, asection *sect, void *arg)
+{
+ struct add_section_info *asi = arg;
+ CORE_ADDR address;
+ char *name;
+
+ /* Ignore non-resident sections. */
+ if ((bfd_get_section_flags(bfd, sect) & (SEC_ALLOC | SEC_LOAD)) == 0)
+ return;
+
+ name = xstrdup(bfd_get_section_name(bfd, sect));
+ make_cleanup(xfree, name);
+ address = asi->base_addr + bfd_get_section_vma(bfd, sect);
+ 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));
+ asi->sect_index++;
+}
+
+static void
+load_kld (char *path, CORE_ADDR base_addr, int from_tty, int add_kld_command)
{
- int sect_index;
+ struct add_section_info asi;
+ struct cleanup *cleanup;
+ bfd *bfd;
+
+ /* Open the kld. */
+ bfd = bfd_openr(path, gnutarget);
+ if (bfd == NULL)
+ error("\"%s\": can't open: %s", path,
+ bfd_errmsg(bfd_get_error()));
+ cleanup = make_cleanup_bfd_close(bfd);
+
+ if (!bfd_check_format(bfd, bfd_object))
+ error("\%s\": not an object file", path);
+
+ /* Make sure we have a .text section. */
+ 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);
+
+ /* 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);
- sect_index = *sect_indexp;
- section_addrs->other[sect_index].name = name;
- section_addrs->other[sect_index].addr = address;
- printf_unfiltered("\t%s_addr = %s\n", name,
- local_hex_string(address));
- sect_index++;
- *sect_indexp = sect_index;
+ do_cleanups(cleanup);
}
void
kgdb_add_kld_cmd (char *arg, int from_tty)
{
- struct section_addr_info *section_addrs;
- struct cleanup *cleanup;
char path[PATH_MAX];
- asection *sect;
CORE_ADDR base_addr;
- bfd *bfd;
- CORE_ADDR text_addr, data_addr, bss_addr, rodata_addr;
- int sect_count, sect_index;
+
+ /* Try to open the raw path to handle absolute paths first. */
+ snprintf(path, sizeof(path), "%s", arg);
+ if (!check_kld_path(path, sizeof(path))) {
- if (!find_kld_path(arg, path, sizeof(path))) {
- error("unable to locate kld");
- return;
+ /*
+ * If that didn't work, look in the various possible
+ * paths for the module.
+ */
+ if (!find_kld_path(arg, path, sizeof(path))) {
+ error("Unable to locate kld");
+ return;
+ }
}
if (!find_kld_address(arg, &base_addr)) {
- error("unable to find kld in kernel");
+ error("Unable to find kld in kernel");
return;
}
- /* Open the kld and find the offsets of the various sections. */
- bfd = bfd_openr(path, gnutarget);
- if (bfd == NULL) {
- error("\"%s\": can't open: %s", path,
- bfd_errmsg(bfd_get_error()));
- return;
+ load_kld(path, base_addr, from_tty, 1);
+
+ reinit_frame_cache();
+}
+
+static void
+kld_relocate_section_addresses (struct so_list *so, struct section_table *sec)
+{
+
+ sec->addr += so->lm_info->base_address;
+ sec->endaddr += so->lm_info->base_address;
+}
+
+static void
+kld_free_so (struct so_list *so)
+{
+
+ xfree(so->lm_info);
+}
+
+static void
+kld_clear_solib (void)
+{
+}
+
+static void
+kld_solib_create_inferior_hook (void)
+{
+}
+
+static void
+kld_special_symbol_handling (void)
+{
+}
+
+static struct so_list *
+kld_current_sos (void)
+{
+ struct so_list *head, **prev, *new;
+ CORE_ADDR kld, kernel;
+ char *path;
+ int error;
+
+ prev = &head;
+
+ /*
+ * 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;
+ kld = read_pointer(kld + off_next)) {
+ /* Skip the main kernel file. */
+ if (kld == kernel)
+ continue;
+
+ new = xmalloc(sizeof(*new));
+ memset(new, 0, sizeof(*new));
+
+ new->lm_info = xmalloc(sizeof(*new->lm_info));
+ new->lm_info->base_address = 0;
+
+ /* Read the base filename and store it in so_original_name. */
+ target_read_string(read_pointer(kld + off_filename),
+ &path, sizeof(new->so_original_name), &error);
+ if (error != 0) {
+ warning("kld_current_sos: Can't read filename: %s\n",
+ safe_strerror(error));
+ free_so(new);
+ continue;
+ }
+ strlcpy(new->so_original_name, path,
+ sizeof(new->so_original_name));
+ xfree(path);
+
+ /*
+ * Try to read the pathname (if it exists) and store
+ * it in so_name.
+ */
+ if (off_pathname != 0) {
+ target_read_string(read_pointer(kld + off_pathname),
+ &path, sizeof(new->so_name), &error);
+ if (error != 0) {
+ warning(
+ "kld_current_sos: Can't read pathname for \"%s\": %s\n",
+ new->so_original_name,
+ safe_strerror(error));
+ strlcpy(new->so_name, new->so_original_name,
+ sizeof(new->so_name));
+ } else {
+ strlcpy(new->so_name, path,
+ sizeof(new->so_name));
+ xfree(path);
+ }
+ } else
+ strlcpy(new->so_name, new->so_original_name,
+ sizeof(new->so_name));
+
+ /* Read this kld's base address. */
+ new->lm_info->base_address = read_pointer(kld + off_address);
+ if (new->lm_info->base_address == 0) {
+ warning(
+ "kld_current_sos: Invalid address for kld \"%s\"",
+ new->so_original_name);
+ free_so(new);
+ continue;
+ }
+
+ /* Append to the list. */
+ *prev = new;
+ prev = &new->next;
}
- cleanup = make_cleanup_bfd_close(bfd);
+
+ return (head);
+}
+
+static int
+kld_open_symbol_file_object (void *from_ttyp)
+{
+
+ return (0);
+}
+
+static int
+kld_in_dynsym_resolve_code (CORE_ADDR pc)
+{
+
+ return (0);
+}
- if (!bfd_check_format(bfd, bfd_object)) {
- do_cleanups(cleanup);
- error("\%s\": not an object file", path);
- return;
- }
+static int
+kld_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
+{
+ char path[PATH_MAX];
+ int fd;
- data_addr = bss_addr = rodata_addr = 0;
- sect = bfd_get_section_by_name (bfd, ".text");
- if (sect == NULL) {
- do_cleanups(cleanup);
- error("\"%s\": can't find text section", path);
- return;
+ *temp_pathname = NULL;
+ if (!find_kld_path(solib, path, sizeof(path))) {
+ errno = ENOENT;
+ return (-1);
}
- text_addr = bfd_get_section_vma(bfd, sect);
- sect_count = 1;
+ fd = open(path, o_flags, 0);
+ if (fd >= 0)
+ *temp_pathname = xstrdup(path);
+ return (fd);
+}
- /* Save the offsets of relevant sections. */
- sect = bfd_get_section_by_name (bfd, ".data");
- if (sect != NULL) {
- data_addr = bfd_get_section_vma(bfd, sect);
- sect_count++;
- }
+static int
+load_klds_stub (void *arg)
+{
- sect = bfd_get_section_by_name (bfd, ".bss");
- if (sect != NULL) {
- bss_addr = bfd_get_section_vma(bfd, sect);
- sect_count++;
- }
+ SOLIB_ADD(NULL, 1, ¤t_target, auto_solib_add);
+ return (0);
+}
- sect = bfd_get_section_by_name (bfd, ".rodata");
- if (sect != NULL) {
- rodata_addr = bfd_get_section_vma(bfd, sect);
- sect_count++;
- }
+void
+kgdb_kld_init (void)
+{
+ struct cmd_list_element *c;
- do_cleanups(cleanup);
+ /* 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;
- printf_unfiltered("add symbol table from file \"%s\" at\n", path);
+ module_path_addr = kgdb_parse("linker_path");
- /* Build a section table for symbol_file_add(). */
- section_addrs = alloc_section_addr_info(sect_count);
- cleanup = make_cleanup(xfree, section_addrs);
- sect_index = 0;
- add_section(section_addrs, §_index, ".text", base_addr + text_addr);
- if (data_addr != 0)
- add_section(section_addrs, §_index, ".data",
- base_addr + data_addr);
- if (bss_addr != 0)
- add_section(section_addrs, §_index, ".bss",
- base_addr + bss_addr);
- if (rodata_addr != 0)
- add_section(section_addrs, §_index, ".rodata",
- base_addr + rodata_addr);
+ kld_so_ops.relocate_section_addresses = kld_relocate_section_addresses;
+ kld_so_ops.free_so = kld_free_so;
+ kld_so_ops.clear_solib = kld_clear_solib;
+ kld_so_ops.solib_create_inferior_hook = kld_solib_create_inferior_hook;
+ kld_so_ops.special_symbol_handling = kld_special_symbol_handling;
+ kld_so_ops.current_sos = kld_current_sos;
+ kld_so_ops.open_symbol_file_object = kld_open_symbol_file_object;
+ kld_so_ops.in_dynsym_resolve_code = kld_in_dynsym_resolve_code;
+ kld_so_ops.find_and_open_solib = kld_find_and_open_solib;
- symbol_file_add(path, from_tty, section_addrs, 0, OBJF_USERLOADED);
+ current_target_so_ops = &kld_so_ops;
- reinit_frame_cache();
+ catch_errors(load_klds_stub, NULL, NULL, RETURN_MASK_ALL);
- do_cleanups(cleanup);
+ 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.");
+ set_cmd_completer(c, filename_completer);
}
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/kthr.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.9 2008/01/18 18:57:27 emaste Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/kthr.c,v 1.10 2008/01/28 20:33:19 jhb Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -60,10 +60,8 @@
nl[0].n_name = (char *)(uintptr_t)sym;
nl[1].n_name = NULL;
- if (kvm_nlist(kvm, nl) != 0) {
- warnx("kvm_nlist(%s): %s", sym, kvm_geterr(kvm));
+ if (kvm_nlist(kvm, nl) != 0)
return (0);
- }
return (nl[0].n_value);
}
@@ -82,13 +80,17 @@
uintptr_t addr, paddr;
addr = kgdb_lookup("_allproc");
- if (addr == 0)
+ if (addr == 0) {
+ warnx("kvm_nlist(_allproc): %s", kvm_geterr(kvm));
return (NULL);
+ }
kvm_read(kvm, addr, &paddr, sizeof(paddr));
dumppcb = kgdb_lookup("_dumppcb");
- if (dumppcb == 0)
+ if (dumppcb == 0) {
+ warnx("kvm_nlist(_dumppcb): %s", kvm_geterr(kvm));
return (NULL);
+ }
addr = kgdb_lookup("_dumptid");
if (addr != 0)
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/main.c#4 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/main.c,v 1.12 2008/01/17 21:43:12 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/main.c,v 1.14 2008/01/29 23:37:59 jhb Exp $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -72,6 +72,7 @@
static char kvm_err[_POSIX2_LINE_MAX];
static int dumpnr;
+static int quiet;
static int verbose;
static char crashdir[PATH_MAX];
@@ -203,7 +204,6 @@
kgdb_init_target(void)
{
CORE_ADDR bufp;
- bfd *kern_bfd;
int size, rseq, wseq;
int kern_desc;
char c;
@@ -227,7 +227,6 @@
}
set_gdbarch_from_file (kern_bfd);
- bfd_close(kern_bfd);
symbol_file_add_main (kernel, 0);
if (remote)
@@ -239,6 +238,8 @@
* Display the unread portion of the message buffer. This gives the
* user a some initial data to work from.
*/
+ if (quiet)
+ return;
bufp = kgdb_parse("msgbufp->msg_ptr");
size = (int)kgdb_parse("msgbufp->msg_size");
rseq = (int)kgdb_parse("msgbufp->msg_rseq");
@@ -302,7 +303,7 @@
struct stat st;
struct captured_main_args args;
char *s;
- int a, ch, quiet, writecore;
+ int a, ch, writecore;
dumpnr = -1;
==== //depot/projects/vap/gnu/usr.bin/gdb/kgdb/trgt.c#4 (text+ko) ====
@@ -25,16 +25,18 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.7 2008/01/24 19:11:13 jhb Exp $");
+__FBSDID("$FreeBSD: src/gnu/usr.bin/gdb/kgdb/trgt.c,v 1.10 2008/01/29 23:44:34 jhb Exp $");
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/sysctl.h>
#include <sys/user.h>
+#include <err.h>
#include <kvm.h>
#include <defs.h>
#include <command.h>
+#include <exec.h>
#include <frame-unwind.h>
#include <gdbthread.h>
#include <inferior.h>
@@ -45,6 +47,8 @@
static struct target_ops kgdb_trgt_ops;
+bfd *kern_bfd;
+
#define KERNOFF (kgdb_kernbase ())
#define INKERNEL(x) ((x) >= KERNOFF)
@@ -81,11 +85,8 @@
static void
kgdb_trgt_files_info(struct target_ops *target)
{
- struct target_ops *tb;
- tb = find_target_beneath(target);
- if (tb->to_files_info != NULL)
- tb->to_files_info(tb);
+ print_section_info(target, kern_bfd);
}
static void
@@ -207,7 +208,7 @@
kgdb_trgt_ops.to_magic = OPS_MAGIC;
kgdb_trgt_ops.to_shortname = "kernel";
- kgdb_trgt_ops.to_longname = "kernel core files.";
+ kgdb_trgt_ops.to_longname = "kernel core files";
kgdb_trgt_ops.to_doc = "Kernel core files.";
kgdb_trgt_ops.to_stratum = thread_stratum;
kgdb_trgt_ops.to_has_memory = 1;
@@ -222,6 +223,12 @@
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list