From fd131b14832587008e57d3b25487ddcaa9ebdab3 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Fri, 24 Aug 2001 09:12:04 +0000 Subject: [PATCH] Dynamically adapt to kernbase changes on crashdumps, falling back to KERNBASE if the "kernbase" symbol is not present on older kernels. --- gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c | 20 +++++++++++++++++++- gnu/usr.bin/binutils/gdb/kvm-fbsd.c | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c index 9513af304c03..fdfc6a381a36 100644 --- a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c @@ -449,7 +449,25 @@ xfer_umem (memaddr, myaddr, len, write) return n; } -#define KERNOFF ((unsigned)KERNBASE) +static CORE_ADDR +ksym_kernbase() +{ + static CORE_ADDR kernbase; + struct minimal_symbol *sym; + + if (kernbase == 0) + { + sym = lookup_minimal_symbol ("kernbase", NULL, NULL); + if (sym == NULL) { + kernbase = KERNBASE; + } else { + kernbase = SYMBOL_VALUE_ADDRESS (sym); + } + } + return kernbase; +} + +#define KERNOFF (ksym_kernbase()) #define INKERNEL(x) ((x) >= KERNOFF) static CORE_ADDR sbr; diff --git a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c index 9513af304c03..fdfc6a381a36 100644 --- a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c @@ -449,7 +449,25 @@ xfer_umem (memaddr, myaddr, len, write) return n; } -#define KERNOFF ((unsigned)KERNBASE) +static CORE_ADDR +ksym_kernbase() +{ + static CORE_ADDR kernbase; + struct minimal_symbol *sym; + + if (kernbase == 0) + { + sym = lookup_minimal_symbol ("kernbase", NULL, NULL); + if (sym == NULL) { + kernbase = KERNBASE; + } else { + kernbase = SYMBOL_VALUE_ADDRESS (sym); + } + } + return kernbase; +} + +#define KERNOFF (ksym_kernbase()) #define INKERNEL(x) ((x) >= KERNOFF) static CORE_ADDR sbr;