summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-01-29 23:37:59 +0000
committerjhb <jhb@FreeBSD.org>2008-01-29 23:37:59 +0000
commit12a6269e8f4d906c68e0171be4c4ce877c287436 (patch)
tree2229411c1cd19c8329c73f880e648574b482face
parentbddbfed7ecee639fc330ad2064430f1723898b9d (diff)
downloadFreeBSD-src-12a6269e8f4d906c68e0171be4c4ce877c287436.zip
FreeBSD-src-12a6269e8f4d906c68e0171be4c4ce877c287436.tar.gz
Don't close the kernel bfd object during startup. Instead, leave it open
and build a section table from the kernel file so that 'info files' output for kgdb now matches the usage of gdb on a regular file with the exception that we don't list sections for memory in the crash dump.
-rw-r--r--gnu/usr.bin/gdb/kgdb/kgdb.h1
-rw-r--r--gnu/usr.bin/gdb/kgdb/main.c2
-rw-r--r--gnu/usr.bin/gdb/kgdb/trgt.c17
3 files changed, 13 insertions, 7 deletions
diff --git a/gnu/usr.bin/gdb/kgdb/kgdb.h b/gnu/usr.bin/gdb/kgdb/kgdb.h
index 14b220b..637d91d 100644
--- a/gnu/usr.bin/gdb/kgdb/kgdb.h
+++ b/gnu/usr.bin/gdb/kgdb/kgdb.h
@@ -33,6 +33,7 @@ struct thread_info;
extern kvm_t *kvm;
extern char *kernel;
+extern bfd *kern_bfd;
struct kthr {
struct kthr *next;
diff --git a/gnu/usr.bin/gdb/kgdb/main.c b/gnu/usr.bin/gdb/kgdb/main.c
index b9452e2..5e1c9c6 100644
--- a/gnu/usr.bin/gdb/kgdb/main.c
+++ b/gnu/usr.bin/gdb/kgdb/main.c
@@ -204,7 +204,6 @@ static void
kgdb_init_target(void)
{
CORE_ADDR bufp;
- bfd *kern_bfd;
int size, rseq, wseq;
int kern_desc;
char c;
@@ -228,7 +227,6 @@ kgdb_init_target(void)
}
set_gdbarch_from_file (kern_bfd);
- bfd_close(kern_bfd);
symbol_file_add_main (kernel, 0);
if (remote)
diff --git a/gnu/usr.bin/gdb/kgdb/trgt.c b/gnu/usr.bin/gdb/kgdb/trgt.c
index 47e96bb..5c39bae 100644
--- a/gnu/usr.bin/gdb/kgdb/trgt.c
+++ b/gnu/usr.bin/gdb/kgdb/trgt.c
@@ -31,10 +31,12 @@ __FBSDID("$FreeBSD$");
#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 @@ __FBSDID("$FreeBSD$");
static struct target_ops kgdb_trgt_ops;
+bfd *kern_bfd;
+
#define KERNOFF (kgdb_kernbase ())
#define INKERNEL(x) ((x) >= KERNOFF)
@@ -81,11 +85,8 @@ kgdb_trgt_extra_thread_info(struct thread_info *ti)
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_target(void)
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 @@ kgdb_target(void)
kgdb_trgt_ops.to_store_registers = kgdb_trgt_store_registers;
kgdb_trgt_ops.to_thread_alive = kgdb_trgt_thread_alive;
kgdb_trgt_ops.to_xfer_memory = kgdb_trgt_xfer_memory;
+
+ if (build_section_table(kern_bfd, &kgdb_trgt_ops.to_sections,
+ &kgdb_trgt_ops.to_sections_end) != 0)
+ errx(1, "\"%s\": can't find the file sections: %s",
+ kernel, bfd_errmsg(bfd_get_error()));
+
add_target(&kgdb_trgt_ops);
push_target(&kgdb_trgt_ops);
OpenPOWER on IntegriCloud