Re: [Crash-utility] Include file for extensions
by Dave Anderson
----- "Luc Chouinard" <Luc.Chouinard(a)trueposition.com> wrote:
> Yes it's fine.
>
> It's been a while now - but I do remember trying relative hard to include defs.h.
> At the time it did look like a bit too much to handle. But like my
> comment says if someone wants to give it a try that would be great.
>
> -Luc
Yeah, it seems to have something to do with your #include of "gdb-6.1/gdb/defs.h"
that causes conflicts -- and which is highly unusual. Even the crash sources
themselves wouldn't go near that gdb header file...
Anyway, OK, I'll just take Michael's patch as is -- thanks!
Dave
15 years, 7 months
Re: [Crash-utility] Include file for extensions
by Dave Anderson
----- "Michael Holzheu" <holzheu(a)linux.vnet.ibm.com> wrote:
> Hi again,
>
> We found a problem in sial. Because sial.c does not include defs.h, for
> all used functions like "ulong symbol_value(char *)", that do not have a
> prototype, the compiler assumes that the return value is int. Therefore
> we get wrong results.
>
> A comment in sial.c says:
>
> // some stuff from crash's defs.h, file which cannot be included here.
> // Hate to do this but this is a quick port..
> // If anyone cares to work on the include and defs structure to make
> // this work cleanly...
>
> If you compile sial with "-Wall" you get:
>
> gcc -g -I.. -Ilibsial -I../gdb-6.1/bfd -I../gdb-6.1/include
> -I../gdb-6.1/gdb -I../gdb-6.1/gdb/config -nostartfiles -shared
> -rdynamic
> -o sial.so sial.c -fPIC -DS390X -Wall -Llibsial -lsial
> sial.c: In function 'apigetmem':
> sial.c:96: warning: implicit declaration of function 'readmem'
> sial.c: In function 'apigetval':
> sial.c:424: warning: implicit declaration of function 'symbol_exists'
> sial.c:425: warning: implicit declaration of function 'symbol_value'
> sial.c: In function 'apigetdefs':
> sial.c:572: warning: implicit declaration of function 'sial_addneg'
> sial.c: In function 'edit_cmd':
> sial.c:676: warning: implicit declaration of function 'cmd_usage'
> sial.c: In function 'rm_sial_cmd':
> sial.c:842: warning: unused variable 'end'
> sial.c: At top level:
> sial.c:917: warning: return type defaults to 'int'
> sial.c: In function '_init':
> sial.c:1013: warning: implicit declaration of function
> 'register_extension'
>
> To solve the problem, we could either define an small official API
> include file for crash extensions (crash.h?), make defs.h include-able
> or just do the quick and ugly fix that declares the missing functions in
> sial.c.
No, there's no need for a "crash.h" file, because by definition crash
extensions modules are *supposed* to #include "defs.h". In fact, the
crash-devel subpackage solely consists of "/usr/include/crash/defs.h"
for extension module writers.
But Luc Chouinard apparently ran into some difficulties with duplicate
declarations or something like that when he did the port.
Anyway, I don't touch the SIAL stuff, and even though the patch below is
fine with me, I'll defer to Luc Chouinard to see if he wants to address
it otherwise. I've cc'd him directly with this response -- he'll probably
say it's fine.
Thanks,
Dave
>
> Michael
>
> The following is the fix for solution (3):
> ---
> extensions/sial.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> Index: crash-4.0-8.9/extensions/sial.c
> ===================================================================
> --- crash-4.0-8.9.orig/extensions/sial.c
> +++ crash-4.0-8.9/extensions/sial.c
> @@ -84,6 +84,13 @@ struct command_table_entry {
> extern FILE *fp;
> extern char *crash_global_cmd();
>
> +typedef unsigned long long int ulonglong;
> +extern int readmem(ulonglong, int, void *, long, char *, ulong);
> +extern int symbol_exists(char *);
> +extern ulong symbol_value(char *);
> +extern void cmd_usage(char *, int);
> +extern void register_extension(struct command_table_entry *);
> +
> //
>
> /////////////////////////////////////////////////////////////////////////
> /*
15 years, 7 months
Include file for extensions
by Michael Holzheu
Hi again,
We found a problem in sial. Because sial.c does not include defs.h, for
all used functions like "ulong symbol_value(char *)", that do not have a
prototype, the compiler assumes that the return value is int. Therefore
we get wrong results.
A comment in sial.c says:
// some stuff from crash's defs.h, file which cannot be included here.
// Hate to do this but this is a quick port..
// If anyone cares to work on the include and defs structure to make
// this work cleanly...
If you compile sial with "-Wall" you get:
gcc -g -I.. -Ilibsial -I../gdb-6.1/bfd -I../gdb-6.1/include
-I../gdb-6.1/gdb -I../gdb-6.1/gdb/config -nostartfiles -shared -rdynamic
-o sial.so sial.c -fPIC -DS390X -Wall -Llibsial -lsial
sial.c: In function 'apigetmem':
sial.c:96: warning: implicit declaration of function 'readmem'
sial.c: In function 'apigetval':
sial.c:424: warning: implicit declaration of function 'symbol_exists'
sial.c:425: warning: implicit declaration of function 'symbol_value'
sial.c: In function 'apigetdefs':
sial.c:572: warning: implicit declaration of function 'sial_addneg'
sial.c: In function 'edit_cmd':
sial.c:676: warning: implicit declaration of function 'cmd_usage'
sial.c: In function 'rm_sial_cmd':
sial.c:842: warning: unused variable 'end'
sial.c: At top level:
sial.c:917: warning: return type defaults to 'int'
sial.c: In function '_init':
sial.c:1013: warning: implicit declaration of function
'register_extension'
To solve the problem, we could either define an small official API
include file for crash extensions (crash.h?), make defs.h include-able
or just do the quick and ugly fix that declares the missing functions in
sial.c.
Michael
The following is the fix for solution (3):
---
extensions/sial.c | 7 +++++++
1 file changed, 7 insertions(+)
Index: crash-4.0-8.9/extensions/sial.c
===================================================================
--- crash-4.0-8.9.orig/extensions/sial.c
+++ crash-4.0-8.9/extensions/sial.c
@@ -84,6 +84,13 @@ struct command_table_entry {
extern FILE *fp;
extern char *crash_global_cmd();
+typedef unsigned long long int ulonglong;
+extern int readmem(ulonglong, int, void *, long, char *, ulong);
+extern int symbol_exists(char *);
+extern ulong symbol_value(char *);
+extern void cmd_usage(char *, int);
+extern void register_extension(struct command_table_entry *);
+
//
/////////////////////////////////////////////////////////////////////////
/*
15 years, 7 months
[PATCH] Support cpu_map/cpu_mask changes in 2.6.29 & module debuginfo search
by Dave Anderson
Hi Michael,
I made a few other changes to your cpu map/mask patch:
- cpu_map_size() has been changed to use the symbol-name-creation
scheme as cpu_map_addr() in order to absolutely maintain the
backwards-compatibility issue brought up by Robin. So if the
old symbol names still exist, the code does exactly the same
thing that it used to.
- Your changes to get_cpus_present() and get_cpus_possible() were
incomplete because they were still using the hardwired "cpus_present_map"
and "cpus_possible_map" symbols.
- I didn't change the s390.c and s390x.c s390[x]_get_smp_cpus()
functions beyond what you did, but I think they should be
changed to use get_cpus_online() instead of the way they
are doing it now. As it is now, they are restricting themselves
to the number of cpu bits in a per-arch long. If the
s390 CONFIG_NR_CPUS can exceed 32, or the s390x CONFIG_NR_CPUS
can exceed 64, then those two functions are incorrect.
If the architecture limits them to 32/64, then I suppose the
way it's done now is OK. That's your call...
Also, the attached patch contains the changes for searching
for kernel module debuginfo files in the same directory tree
specified with "mod -S <directory>". Alternatively there
is a new "crash --mod <directory>" command line option, such
that "mod -S" with no directory argument will default to
searching the command-line specified directory.
Anyway, I've only tested this on older kernels that still have
the "cpu_xxxx_map" symbols. Can you test the patch on new
kernels? And also let me know whether the s390[x] functions
should be updated.
Thanks,
Dave
15 years, 7 months
Re: [Crash-utility] [PATCH] Support cpu_map/cpu_mask changes in 2.6.29 & module debuginfo search
by Dave Anderson
> Anyway, I've only tested this on older kernels that still have
> the "cpu_xxxx_map" symbols. Can you test the patch on new
> kernels? And also let me know whether the s390[x] functions
> should be updated.
One more thing -- this whole cpu_xxxx_map->cpu_xxxx_mask issue only
affects s390, s390x and ppc64, correct? The s390[x] architectures
unconditionally require "cpu_online_map" to exist in their
respective s390[x]_get_smp_cpus() functions. And ppc64 requires
the existence of either cpu_present_map or cpu_online_map in
its ppc64_paca_init() function. But the other architectures look
like they get along without them.
Dave
15 years, 7 months
Re: [Crash-utility] [PATCH] Support cpu_map/cpu_mask changes in 2.6.29
by Dave Anderson
----- "Michael Holzheu" <holzheu(a)linux.vnet.ibm.com> wrote:
> Hi Dave,
>
> I tested my patch and it worked. But it only worked by chance. I read
> the address using readmem(cpu_mask_size) in combination with ULONG(),
> which is nonsense.
>
> So the correct (and tested) version would be something like:
>
> static ulong
> get_cpu_map_addr_from_mask(const char *type)
> {
> char cpu_mask_symbol[32];
> ulong cpu_map_addr;
>
> sprintf(cpu_mask_symbol, "cpu_%s_mask", type);
>
> if (!symbol_exists(cpu_mask_symbol))
> return 0;
>
> get_symbol_data(cpu_mask_symbol, sizeof(ulong), &cpu_map_addr);
> return cpu_map_addr;
> }
OK good -- I'll probably just fold the above into cpu_map_addr().
Also, this change, although it doesn't break things, doesn't make
sense because this instance of "cpu_online_map" is a symbol in the
xen hypervisor binary, i.e., not the one in the vmlinux code:
--- crash-4.0-8.9.orig/xen_hyper.c
+++ crash-4.0-8.9/xen_hyper.c
@@ -1815,7 +1815,7 @@ xen_hyper_get_cpu_info(void)
error(FATAL, "cannot malloc cpumask space.\n");
}
/* kakuma: It may be better to use cpu_present_map. */
- addr = symbol_value("cpu_online_map");
+ addr = cpu_map_addr("online");
if (!readmem(addr, KVADDR, xht->cpumask,
XEN_HYPER_SIZE(cpumask_t), "cpu_online_map", RETURN_ON_ERROR)) {
error(FATAL, "cannot read cpu_online_map.\n");
Thanks,
Dave
15 years, 7 months
Re: [Crash-utility] [PATCH] Support cpu_map/cpu_mask changes in 2.6.29
by Dave Anderson
Michael,
It's not clear to me how this function works:
+ * Get cpu map (possible, online, etc.) address from cpu mask (since 2.6.29)
+ */
+static ulong
+get_cpu_map_addr_from_mask(const char *type)
+{
+ ulong cpu_mask_addr, cpu_map_addr;
+ char cpu_mask_symbol[32];
+ char *cpu_mask_buf;
+ int cpu_mask_size;
+
+ sprintf(cpu_mask_symbol, "cpu_%s_mask", type);
+
+ if (!symbol_exists(cpu_mask_symbol))
+ return 0;
+
+ cpu_mask_addr = symbol_value(cpu_mask_symbol);
+ cpu_mask_size = STRUCT_SIZE("cpumask");
+ cpu_mask_buf = malloc(cpu_mask_size);
+ if (!cpu_mask_buf)
+ error(FATAL, "get_cpu_map_addr_from_mask: out of memory\n");
+ readmem(cpu_mask_addr, KVADDR, cpu_mask_buf, cpu_mask_size,
+ cpu_mask_symbol, FAULT_ON_ERROR);
+ cpu_map_addr = ULONG(cpu_mask_buf + MEMBER_OFFSET("cpumask", "bits"));
+ free(cpu_mask_buf);
+
+ return cpu_map_addr;
+}
The caller to this function expects the address of a cpumask_t
data structure. As I understand it, both before and after 2.6.29,
the cpumask data structure looks like:
typedef struct cpumask {
unsigned long int bits[<variable-based-upon-NR_CPUS>];
} cpumask_t;
And pre-2.6.29, the 3 "cpu_xxxx_map" symbols were all statically
defined cpumask structures:
cpumask_t cpu_online_mask;
cpumask_t cpu_possible_mask;
cpumask_t cpu_present_mask;
Whereas now the 3 symbols don't exist except as #define's like so:
#define cpu_possible_map (*(cpumask_t *)cpu_possible_mask)
#define cpu_online_map (*(cpumask_t *)cpu_online_mask)
#define cpu_present_map (*(cpumask_t *)cpu_present_mask)
and -- if I understand the code correctly -- each cpu_xxxx_mask
is just a pointer to a cpumask data structure.
So when the caller needs the address of the relevant cpumask data structure
why doesn't your cpu_map_addr_from_mask() function simply do something
like:
get_symbol_data(cpu_mask_symbol, sizeof(void *), &tmp);
return tmp;
i.e., which would read the contents of the cpu_mask_symbol, which
is the pointer that the caller wants.
Instead, your function reads in the whole data structure, where
the cpumask.bits[] array typically contains several items, i.e.,
enough longs to contain NR_CPUS bits. Then, with ULONG(), it is
essentially reading the unsigned long value found in the first
bit[] array item, or:
cpumask.bits[0];
and therefore returning the *bitmask* contained in the first unsigned
long in the bit[] array -- instead of the *address* of the cpumask
data structure. How can that work?
Or am I missing something?
(Sorry -- I just started looking at this again, but I don't have
a test kernel of this vintage to play with...)
Dave
15 years, 7 months
Re: [Crash-utility] [PATCH] Support cpu_map/cpu_mask changes in 2.6.29
by Dave Anderson
----- "Robin Holt" <holt(a)sgi.com> wrote:
> On Mon, Apr 27, 2009 at 10:27:22AM -0400, Dave Anderson wrote:
> >
> > ----- "Michael Holzheu" <holzheu(a)linux.vnet.ibm.com> wrote:
> >
> > > > So yes, while STRUCT_SIZE("cpumask_t") would always be appropriate for that
> > > > data type, it would fail for the older kernel types which don't use it.
> > >
> > > So if for older kernels it was an unsigned long, the function should
> > > work:
> > >
> > > +static int
> > > +cpu_map_size(void)
> > > +{
> > > + int len;
> > > +
> > > + len = STRUCT_SIZE("cpumask_t");
> > > + if (len < 0)
> > > + return sizeof(ulong);
> > > + else
> > > + return len;
> > > +}
> >
> > Yeah, you're right, that will probably work. There were definitions for
> > "cpumask_t" that existed prior to the transition of cpu_online_map symbol
> > from being an unsigned long to a cpumask_t. But except for mips64 (unsupported)
> > they all appear to have been unsigned longs anyway.
>
> IIRC, cpumask_t on ia64 hasn't been an unsigned long for a very long time.
> The generic_defconfig was at 512 until it recently jumped to 2048.
> Only some configs limited it down to an unsigned long. Unfortunately,
> I don't have much time to test this week. Maybe next, but a quick code
> inspection should raise flags if I am remembering correctly.
>
> Thanks,
> Robin
OK, so then there are two functions in Michael's patch that are
primarily relevant to maintaining backwards compatibility, cpu_map_addr()
and cpu_map_size().
cpu_map_addr() basically replaces the hardwired usage of the relevant
symbol address as an argument to kernel_symbol_exists("cpu_xxxx_map").
But when the pre-2.6.29 "cpu_xxxx_map" symbols exist, the code still
does the right thing:
+ulong
+cpu_map_addr(const char *type)
+{
+ char cpu_map_symbol[32];
+
+ sprintf(cpu_map_symbol, "cpu_%s_map", type);
+ if (symbol_exists(cpu_map_symbol))
+ return symbol_value(cpu_map_symbol);
+ else
+ return get_cpu_map_addr_from_mask(type);
+}
Although, for safety's sake above, the symbol_value() call should
be replaced with kernel_symbol_value() in order to rule out the
invalid usage of stray module symbols of the same name.
The cpu_map_size() function is the real bone of contention:
+static int
+cpu_map_size(void)
+{
+ int len;
+
+ len = STRUCT_SIZE("cpumask_t");
+ if (len < 0)
+ return sizeof(ulong);
+ else
+ return len;
+}
because it is used like so:
- if (LKCD_KERNTYPES()) {
- if ((len = STRUCT_SIZE("cpumask_t")) < 0)
- error(FATAL, "cannot determine type cpumask_t\n");
- } else
- len = get_symbol_type("cpu_online_map", NULL, &req) ==
- TYPE_CODE_UNDEF ? sizeof(ulong) : req.length;
+ len = cpu_map_size();
So to cover all bases, perhaps cpu_map_size() should still incorporate
the get_symbol_type() mechanism *if* the "cpu_xxxx_map" symbol still
exists?
Michael, does that make sense?
Dave
15 years, 7 months
Re: [Crash-utility] [PATCH] Support cpu_map/cpu_mask changes in 2.6.29
by Dave Anderson
----- "Michael Holzheu" <holzheu(a)linux.vnet.ibm.com> wrote:
> > So yes, while STRUCT_SIZE("cpumask_t") would always be appropriate for that
> > data type, it would fail for the older kernel types which don't use it.
>
> So if for older kernels it was an unsigned long, the function should
> work:
>
> +static int
> +cpu_map_size(void)
> +{
> + int len;
> +
> + len = STRUCT_SIZE("cpumask_t");
> + if (len < 0)
> + return sizeof(ulong);
> + else
> + return len;
> +}
Yeah, you're right, that will probably work. There were definitions for
"cpumask_t" that existed prior to the transition of cpu_online_map symbol
from being an unsigned long to a cpumask_t. But except for mips64 (unsupported)
they all appear to have been unsigned longs anyway.
So it should in all probability be safe. Let me play around with the patch.
Thanks again for taking the time to work this out,
Dave
15 years, 7 months
Re: [Crash-utility] [PATCH] Support cpu_map/cpu_mask changes in 2.6.29
by Dave Anderson
----- "Michael Holzheu" <holzheu(a)linux.vnet.ibm.com> wrote:
> Hi Dave,
>
> I found some time to fix the cpu_map issue in 2.6.29.
> Here my proposal:
Thanks, man -- much appreciated...
> From: Michael Holzheu <holzheu(a)linux.vnet.ibm.com>
>
> In Linux 2.6.29 the cpu_(online, possible, present, active)_map global variables
> have been moved to cpu_(...)_mask variables that are pointers to structures
> with bitmaps now. This patch allows crash to work with the new variables.
>
> Note: The cpu_map_size() function now only uses STRUCT_SIZE("cpumask_t")
> to get the size of the cpu map. I removed the get_symbol_type() call
> since STRUCT_SIZE("cpumask_t") should always work.
>
> Correct me if I am wrong here!
Actually, this would break backwards compatibility. The "cpu_online_map"
used to be an "unsigned long", back when NR_CPUS was hardwired to 32.
So the get_symbol_type() is used to differentiate between that type and
its current invocation as a variably-sized cpumask_t struct based upon
NR_CPUS.
So yes, while STRUCT_SIZE("cpumask_t") would always be appropriate for that
data type, it would fail for the older kernel types which don't use it.
Dave
>
> Signed-off-by: Michael Holzheu <holzheu(a)linux.vnet.ibm.com>
> ---
> defs.h | 1
> kernel.c | 111
> ++++++++++++++++++++++++++++++++++++++++++------------------
> ppc64.c | 4 +-
> s390.c | 3 +
> s390x.c | 3 +
> xen_hyper.c | 2 -
> 6 files changed, 86 insertions(+), 38 deletions(-)
>
> Index: crash-4.0-8.9/defs.h
> ===================================================================
> --- crash-4.0-8.9.orig/defs.h
> +++ crash-4.0-8.9/defs.h
> @@ -3647,6 +3647,7 @@ int in_cpu_map(int, int);
> void paravirt_init(void);
> void print_stack_text_syms(struct bt_info *, ulong, ulong);
> void back_trace(struct bt_info *);
> +ulong cpu_map_addr(const char *type);
> #define BT_RAW (0x1ULL)
> #define BT_SYMBOLIC_ARGS (0x2ULL)
> #define BT_FULL (0x4ULL)
> Index: crash-4.0-8.9/kernel.c
> ===================================================================
> --- crash-4.0-8.9.orig/kernel.c
> +++ crash-4.0-8.9/kernel.c
> @@ -533,6 +533,65 @@ kernel_init()
> }
>
> /*
> + * Get cpu map (possible, online, etc.) address from cpu mask (since
> 2.6.29)
> + */
> +static ulong
> +get_cpu_map_addr_from_mask(const char *type)
> +{
> + ulong cpu_mask_addr, cpu_map_addr;
> + char cpu_mask_symbol[32];
> + char *cpu_mask_buf;
> + int cpu_mask_size;
> +
> + sprintf(cpu_mask_symbol, "cpu_%s_mask", type);
> +
> + if (!symbol_exists(cpu_mask_symbol))
> + return 0;
> +
> + cpu_mask_addr = symbol_value(cpu_mask_symbol);
> + cpu_mask_size = STRUCT_SIZE("cpumask");
> + cpu_mask_buf = malloc(cpu_mask_size);
> + if (!cpu_mask_buf)
> + error(FATAL, "get_cpu_map_addr_from_mask: out of memory\n");
> + readmem(cpu_mask_addr, KVADDR, cpu_mask_buf, cpu_mask_size,
> + cpu_mask_symbol, FAULT_ON_ERROR);
> + cpu_map_addr = ULONG(cpu_mask_buf + MEMBER_OFFSET("cpumask",
> "bits"));
> + free(cpu_mask_buf);
> +
> + return cpu_map_addr;
> +}
> +
> +/*
> + * Get cpu map address. Types are: possible, online, present and
> active
> + */
> +ulong
> +cpu_map_addr(const char *type)
> +{
> + char cpu_map_symbol[32];
> +
> + sprintf(cpu_map_symbol, "cpu_%s_map", type);
> + if (symbol_exists(cpu_map_symbol))
> + return symbol_value(cpu_map_symbol);
> + else
> + return get_cpu_map_addr_from_mask(type);
> +}
> +
> +/*
> + * Get cpu map (possible, online, etc.) size
> + */
> +static int
> +cpu_map_size(void)
> +{
> + int len;
> +
> + len = STRUCT_SIZE("cpumask_t");
> + if (len < 0)
> + return sizeof(ulong);
> + else
> + return len;
> +}
> +
> +/*
> * If the cpu_present_map, cpu_online_map and cpu_possible_maps
> exist,
> * set up the kt->cpu_flags[NR_CPUS] with their settings.
> */
> @@ -546,9 +605,9 @@ cpu_maps_init(void)
> ulong cpu_flag;
> char *name;
> } mapinfo[] = {
> - { POSSIBLE, "cpu_possible_map" },
> - { PRESENT, "cpu_present_map" },
> - { ONLINE, "cpu_online_map" },
> + { POSSIBLE, "possible" },
> + { PRESENT, "present" },
> + { ONLINE, "online" },
> };
>
> if ((len = STRUCT_SIZE("cpumask_t")) < 0)
> @@ -557,12 +616,13 @@ cpu_maps_init(void)
> buf = GETBUF(len);
>
> for (m = 0; m < sizeof(mapinfo)/sizeof(struct mapinfo); m++) {
> - if (!kernel_symbol_exists(mapinfo[m].name))
> + if (!cpu_map_addr(mapinfo[m].name))
> continue;
>
> - if (!readmem(symbol_value(mapinfo[m].name), KVADDR, buf, len,
> + if (!readmem(cpu_map_addr(mapinfo[m].name), KVADDR, buf, len,
> mapinfo[m].name, RETURN_ON_ERROR)) {
> - error(WARNING, "cannot read %s\n", mapinfo[m].name);
> + error(WARNING, "cannot read cpu_%s_map\n",
> + mapinfo[m].name);
> continue;
> }
>
> @@ -578,7 +638,7 @@ cpu_maps_init(void)
> }
>
> if (CRASHDEBUG(1)) {
> - fprintf(fp, "%s: ", mapinfo[m].name);
> + fprintf(fp, "cpu_%s_map: ", mapinfo[m].name);
> for (i = 0; i < NR_CPUS; i++) {
> if (kt->cpu_flags[i] & mapinfo[m].cpu_flag)
> fprintf(fp, "%d ", i);
> @@ -605,21 +665,21 @@ in_cpu_map(int map, int cpu)
> switch (map)
> {
> case POSSIBLE:
> - if (!kernel_symbol_exists("cpu_possible_map")) {
> + if (!cpu_map_addr("possible")) {
> error(INFO, "cpu_possible_map does not exist\n");
> return FALSE;
> }
> return (kt->cpu_flags[cpu] & POSSIBLE);
>
> case PRESENT:
> - if (!kernel_symbol_exists("cpu_present_map")) {
> + if (!cpu_map_addr("present")) {
> error(INFO, "cpu_present_map does not exist\n");
> return FALSE;
> }
> return (kt->cpu_flags[cpu] & PRESENT);
>
> case ONLINE:
> - if (!kernel_symbol_exists("cpu_online_map")) {
> + if (!cpu_map_addr("online")) {
> error(INFO, "cpu_online_map does not exist\n");
> return FALSE;
> }
> @@ -4187,7 +4247,7 @@ dump_kernel_table(int verbose)
> }
> fprintf(fp, "\n");
> fprintf(fp, " cpu_possible_map: ");
> - if (kernel_symbol_exists("cpu_possible_map")) {
> + if (cpu_map_addr("possible")) {
> for (i = 0; i < nr_cpus; i++) {
> if (kt->cpu_flags[i] & POSSIBLE)
> fprintf(fp, "%d ", i);
> @@ -4196,7 +4256,7 @@ dump_kernel_table(int verbose)
> } else
> fprintf(fp, "(does not exist)\n");
> fprintf(fp, " cpu_present_map: ");
> - if (kernel_symbol_exists("cpu_present_map")) {
> + if (cpu_map_addr("present")) {
> for (i = 0; i < nr_cpus; i++) {
> if (kt->cpu_flags[i] & PRESENT)
> fprintf(fp, "%d ", i);
> @@ -4205,7 +4265,7 @@ dump_kernel_table(int verbose)
> } else
> fprintf(fp, "(does not exist)\n");
> fprintf(fp, " cpu_online_map: ");
> - if (kernel_symbol_exists("cpu_online_map")) {
> + if (cpu_map_addr("online")) {
> for (i = 0; i < nr_cpus; i++) {
> if (kt->cpu_flags[i] & ONLINE)
> fprintf(fp, "%d ", i);
> @@ -5927,20 +5987,15 @@ get_cpus_online()
> char *buf;
> ulong *maskptr;
>
> - if (!symbol_exists("cpu_online_map"))
> + if (!cpu_map_addr("online"))
> return 0;
>
> - if (LKCD_KERNTYPES()) {
> - if ((len = STRUCT_SIZE("cpumask_t")) < 0)
> - error(FATAL, "cannot determine type cpumask_t\n");
> - } else
> - len = get_symbol_type("cpu_online_map", NULL, &req) ==
> - TYPE_CODE_UNDEF ? sizeof(ulong) : req.length;
> + len = cpu_map_size();
> buf = GETBUF(len);
>
> online = 0;
>
> - if (readmem(symbol_value("cpu_online_map"), KVADDR, buf,
> len,
> + if (readmem(cpu_map_addr("online"), KVADDR, buf, len,
> "cpu_online_map", RETURN_ON_ERROR)) {
>
> maskptr = (ulong *)buf;
> @@ -5969,12 +6024,7 @@ get_cpus_present()
> if (!symbol_exists("cpu_present_map"))
> return 0;
>
> - if (LKCD_KERNTYPES()) {
> - if ((len = STRUCT_SIZE("cpumask_t")) < 0)
> - error(FATAL, "cannot determine type cpumask_t\n");
> - } else
> - len = get_symbol_type("cpu_present_map", NULL, &req) ==
> - TYPE_CODE_UNDEF ? sizeof(ulong) : req.length;
> + len = cpu_map_size();
> buf = GETBUF(len);
>
> present = 0;
> @@ -6008,12 +6058,7 @@ get_cpus_possible()
> if (!symbol_exists("cpu_possible_map"))
> return 0;
>
> - if (LKCD_KERNTYPES()) {
> - if ((len = STRUCT_SIZE("cpumask_t")) < 0)
> - error(FATAL, "cannot determine type cpumask_t\n");
> - } else
> - len = get_symbol_type("cpu_possible_map", NULL, &req) ==
> - TYPE_CODE_UNDEF ? sizeof(ulong) : req.length;
> + len = cpu_map_size();
> buf = GETBUF(len);
>
> possible = 0;
> Index: crash-4.0-8.9/s390.c
> ===================================================================
> --- crash-4.0-8.9.orig/s390.c
> +++ crash-4.0-8.9/s390.c
> @@ -1001,7 +1001,8 @@ s390_get_smp_cpus(void)
> {
> unsigned long map = 0, addr;
> int i, cpu_num = 0;
> - addr=symbol_value("cpu_online_map");
> +
> + addr = cpu_map_addr("online");
> readmem(addr, KVADDR, &map,sizeof(long),
> "cpu_online_map",FAULT_ON_ERROR);
> for(i = 0; i < sizeof(map)*8;i++){
> if(map & 0x1UL)
> Index: crash-4.0-8.9/s390x.c
> ===================================================================
> --- crash-4.0-8.9.orig/s390x.c
> +++ crash-4.0-8.9/s390x.c
> @@ -1031,7 +1031,8 @@ s390x_get_smp_cpus(void)
> {
> unsigned long map = 0, addr;
> int i, cpu_num = 0;
> - addr=symbol_value("cpu_online_map");
> +
> + addr = cpu_map_addr("online");
> readmem(addr, KVADDR, &map,sizeof(long),
> "cpu_online_map",FAULT_ON_ERROR);
> for(i = 0; i < sizeof(map)*8;i++){
> if(map & 0x1UL)
> Index: crash-4.0-8.9/ppc64.c
> ===================================================================
> --- crash-4.0-8.9.orig/ppc64.c
> +++ crash-4.0-8.9/ppc64.c
> @@ -2407,9 +2407,9 @@ ppc64_paca_init(void)
> if (!symbol_exists("paca"))
> error(FATAL, "PPC64: Could not find 'paca' symbol\n");
>
> - if (symbol_exists("cpu_present_map"))
> + if (cpu_map_addr("present"))
> map = PRESENT;
> - else if (symbol_exists("cpu_online_map"))
> + else if (cpu_map_addr("online"))
> map = ONLINE;
> else
> error(FATAL,
> Index: crash-4.0-8.9/xen_hyper.c
> ===================================================================
> --- crash-4.0-8.9.orig/xen_hyper.c
> +++ crash-4.0-8.9/xen_hyper.c
> @@ -1815,7 +1815,7 @@ xen_hyper_get_cpu_info(void)
> error(FATAL, "cannot malloc cpumask space.\n");
> }
> /* kakuma: It may be better to use cpu_present_map. */
> - addr = symbol_value("cpu_online_map");
> + addr = cpu_map_addr("online");
> if (!readmem(addr, KVADDR, xht->cpumask,
> XEN_HYPER_SIZE(cpumask_t), "cpu_online_map", RETURN_ON_ERROR)) {
> error(FATAL, "cannot read cpu_online_map.\n");
>
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
15 years, 7 months