sial output redirection
by Denman, Robert
Luc,
The following patch will allow the output of SIAL commands to be
redirected to a file or pipe. I did not handle all cases supported by
crash (e.g. multi-pipes), only simple output redirection. Would you
please consider this change or something like it in the next release?
Thanks.
- Robert -
Generated By: Teradata Corporation (Mon Nov 12 15:29:56 PST 2007)
extensions.c | 12
++++++++++++++++++++++++++++++++++++++++++++++++++++++
extensions/sial.c | 7 +++++++++++++++++++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)
Index: crash-4.0-4.8/extensions/sial.c
===================================================================
--- crash-4.0-4.8-orig/extensions/sial.c 2007-10-30
08:51:54.000000000 -0
700
+++ crash-4.0-4.8/extensions/sial.c 2007-11-12 15:28:55.000000000
-0800
@@ -638,6 +638,13 @@
run_callback(void)
{
extern char *crash_global_cmd();
+extern FILE *crash_cmd_filep();
+
+ FILE *fp;
+
+ if ((fp = crash_cmd_filep()) != NULL) {
+ sial_setofile(fp);
+ }
sial_cmd(crash_global_cmd(), args, argcnt);
}
Index: crash-4.0-4.8/extensions.c
===================================================================
--- crash-4.0-4.8-orig/extensions.c 2007-10-30 08:51:54.000000000
-0700
+++ crash-4.0-4.8/extensions.c 2007-11-12 15:27:21.000000000 -0800
@@ -374,3 +374,15 @@
{
return pc->cmd_table;
}
+
+FILE *
+crash_cmd_filep(void)
+{
+ if (pc->redirect & REDIRECT_TO_FILE) {
+ return pc->ofile;
+ } else if (pc->redirect & REDIRECT_TO_PIPE) {
+ return pc->pipe;
+ } else {
+ return NULL;
+ }
+}
17 years
[PATCH] Fix overflow problem of "kmem -p" on i386 SPARSEMEM
by Ken'ichi Ohmichi
Hi,
This patch fixes the overflow problem that "kmem -p" cannot display
the physical addresses properly on i386 SPARSEMEM kernel.
Before applying this patch:
crash> kmem -p
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
[snip]
cb000260 ffffb000 ------- ----- 1 e000400
cb000280 ffffc000 ------- ----- 1 e000400
cb0002a0 ffffd000 ------- ----- 1 e000400
cb0002c0 ffffe000 ------- ----- 1 e000400
cb0002e0 fffff000 ------- ----- 1 e000400
cb000400 0 ------- ----- 0 12080000
cb000420 1000 ------- ----- 0 12000000
cb000440 2000 ------- ----- 0 12000000
cb000460 3000 ------- ----- 0 12000000
cb000480 4000 ------- ----- 0 12000000
After applying this patch:
crash> kmem -p
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
[snip]
cb000260 ffffb000 ------- ----- 1 e000400
cb000280 ffffc000 ------- ----- 1 e000400
cb0002a0 ffffd000 ------- ----- 1 e000400
cb0002c0 ffffe000 ------- ----- 1 e000400
cb0002e0 fffff000 ------- ----- 1 e000400
cb000400 100000000 ------- ----- 0 12080000
cb000420 100001000 ------- ----- 0 12000000
cb000440 100002000 ------- ----- 0 12000000
cb000460 100003000 ------- ----- 0 12000000
cb000480 100004000 ------- ----- 0 12000000
This problem can be reproduced on the following environment:
The crash utility:
crash-4.0-4.8
+ [PATCH] display information about "struct page" on SPARSEMEM.(2007/11/02)
System:
CPU: i386
MEM: 4GB or bigger
Kernel:
i386, PAE, SPARSEMEM
Thanks
Ken'ichi Ohmichi
Signed-off-by: Ken'ichi Ohmichi <oomichi(a)mxs.nes.nec.co.jp>
---
diff -rpuN crash-4.0-4.8.org/memory.c crash-4.0-4.8/memory.c
--- crash-4.0-4.8.org/memory.c 2007-10-31 11:49:16.000000000 +0900
+++ crash-4.0-4.8/memory.c 2007-11-13 15:48:31.000000000 +0900
@@ -4004,7 +4004,7 @@ dump_mem_map_SPARSEMEM(struct meminfo *m
pp = section_mem_map_addr(section);
pp = sparse_decode_mem_map(pp, section_nr);
- phys = section_nr * PAGES_PER_SECTION() * PAGESIZE();
+ phys = (physaddr_t) section_nr * PAGES_PER_SECTION() * PAGESIZE();
section_size = PAGES_PER_SECTION();
for (i = 0; i < section_size;
_
17 years
[PATCH] Fix compile warnings
by Bernhard Walle
This fixes compiler warnings with
-O2 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector \
-fno-builtin-memset -fno-strict-aliasing
Yes, for the one in get_lkcd_regs_for_cpu_v8() you can blame myself.
Signed-off-by: Bernhard Walle <bwalle(a)suse.de>
---
lkcd_common.c | 2 +-
lkcd_v8.c | 4 +---
symbols.c | 3 +++
3 files changed, 5 insertions(+), 4 deletions(-)
--- a/lkcd_common.c
+++ b/lkcd_common.c
@@ -1265,7 +1265,7 @@ lkcd_uncompress_gzip(unsigned char *dest
unsigned char *source, ulong sourcelen)
{
ulong retlen = destlen;
- int rc;
+ int rc = FALSE;
switch (uncompress(dest, &retlen, source, sourcelen))
{
--- a/lkcd_v8.c
+++ b/lkcd_v8.c
@@ -71,7 +71,7 @@ get_lkcd_regs_for_cpu_arch(int cpu, ulon
int
get_lkcd_regs_for_cpu_v8(struct bt_info *bt, ulong *eip, ulong *esp)
{
- int cpu;
+ int cpu = bt->tc->processor;
if (!bt || !bt->tc) {
fprintf(stderr, "get_lkcd_regs_for_cpu_v8: invalid tc "
@@ -79,8 +79,6 @@ get_lkcd_regs_for_cpu_v8(struct bt_info
return -EINVAL;
}
- cpu = bt->tc->processor;
-
if (cpu >= NR_CPUS) {
fprintf(stderr, "get_lkcd_regs_for_cpu_v8, cpu (%d) too high\n", cpu);
return -EINVAL;
--- a/symbols.c
+++ b/symbols.c
@@ -7538,6 +7538,9 @@ calculate_load_order_v2(struct load_modu
char *secname;
int i;
+ if ((store = bfd_make_empty_symbol(bfd)) == NULL)
+ error(FATAL, "bfd_make_empty_symbol() failed\n");
+
s1 = lm->mod_symtable;
s2 = lm->mod_symend;
while (s1 < s2) {
17 years
[PATCH] Fix compiler warnings in echo extension
by Bernhard Walle
Fixes
echo.c:24: warning: missing braces around initializer
echo.c:24: warning: (near initialization for 'command_table[0]')
echo.c:30: warning: return type defaults to 'int'
echo.c:38: warning: return type defaults to 'int'
echo.c: In function '_fini':
echo.c:38: warning: control reaches end of non-void function
echo.c: In function '_init':
echo.c:32: warning: control reaches end of non-void function
Signed-off-by: Bernhard Walle <bwalle(a)suse.de>
---
extensions/echo.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--- a/extensions/echo.c
+++ b/extensions/echo.c
@@ -21,21 +21,22 @@ void cmd_echo(); /* Declare the comm
char *help_echo[];
static struct command_table_entry command_table[] = {
- "echo", cmd_echo, help_echo, 0, /* One or more commands, */
- NULL, /* terminated by NULL, */
+ { "echo", cmd_echo, help_echo, 0 }, /* One or more commands, */
+ { NULL } /* terminated by NULL, */
};
-_init() /* Register the command set. */
+int _init() /* Register the command set. */
{
register_extension(command_table);
+ return 1;
}
/*
* The _fini() function is called if the shared object is unloaded.
* If desired, perform any cleanups here.
*/
-_fini() { }
+void _fini() { }
/*
17 years
[PATCH] Fix SIAL warnings
by Bernhard Walle
This patch fixes "operation on 'v1' may be undefined" warning in sial_exeop().
In some places V1 and L1 where used as arguments at the same time.
It's from lkcdutils and has been there in CVS for a few month. Originally
written by Jan Blunck <jblunck(a)suse.de>.
Signed-off-by: Bernhard Walle <bwalle(a)suse.de>
---
extensions/libsial/sial_op.c | 95 ++++++++++++++++++++++++++-----------------
1 file changed, 59 insertions(+), 36 deletions(-)
--- a/extensions/libsial/sial_op.c
+++ b/extensions/libsial/sial_op.c
@@ -28,15 +28,15 @@ typedef struct {
#define V3 (v3?v3:(v3=NODE_EXE(P3)))
#define V4 (v4?v4:(v4=NODE_EXE(P4)))
-#define L1 (unival(v1?v1:V1))
-#define L2 (unival(v2?v2:V2))
-#define L3 (unival(v3?v3:V3))
-#define L4 (unival(v4?v4:V4))
-
-#define S1 ((v1?v1:V1)->v.data)
-#define S2 ((v2?v2:V2)->v.data)
-#define S3 ((v3?v3:V3)->v.data)
-#define S4 ((v4?v4:V4)->v.data)
+#define L1 (unival(V1))
+#define L2 (unival(V2))
+#define L3 (unival(V3))
+#define L4 (unival(V4))
+
+#define S1 ((V1)->v.data)
+#define S2 ((V2)->v.data)
+#define S3 ((V3)->v.data)
+#define S4 ((V4)->v.data)
void sial_do_deref(int n, value_t *v, value_t *ref);
ul
@@ -545,39 +545,53 @@ inval:
case ADD: { /* expr + expr */
/* adding two pointers ? */
if(V2->type.type == V_REF) goto inval;
- sial_transfer(v=sial_newval(), V1, L1 + L2*size);
+
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) + L2 * size);
}
break;
case SUB: { /* expr - expr */
-
/* different results if mixed types.
if both are pointers then result is a V_BASE */
if(V2->type.type == V_REF)
v=sial_makebtype(L1 - L2);
- else sial_transfer(v=sial_newval(), V1, L1 - L2*size);
+ else {
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) - L2 * size);
+ }
}
break;
case PREDECR: { /* pre is easy */
- sial_transfer(v=sial_newval(), V1, L1-size);
- sial_setval(V1, v);
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) - size);
+ sial_setval(v1, v);
}
break;
case PREINCR: {
- sial_transfer(v=sial_newval(), V1, L1+size);
- sial_setval(V1, v);
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) + size);
+ sial_setval(v1, v);
}
break;
case POSTINCR: {
- sial_transfer(v=sial_newval(), V1, L1+size);
- sial_setval(V1, v);
- sial_transfer(v, V1, L1);
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) + size);
+ sial_setval(v1, v);
+ sial_transfer(v, v1, unival(v1));
}
break;
case POSTDECR: {
- sial_transfer(v=sial_newval(), V1, L1-size);
- sial_setval(V1, v);
- sial_transfer(v, V1, L1);
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) - size);
+ sial_setval(v1, v);
+ sial_transfer(v, v1, unival(v1));
}
break;
default:
@@ -625,26 +639,33 @@ inval:
}
break;
case PREDECR: { /* pre is easy */
- sial_transfer(v=sial_newval(), V1, L1-1);
- sial_setval(V1, v);
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) - 1);
+ sial_setval(v1, v);
}
break;
case PREINCR: {
V1;
- sial_transfer(v=sial_newval(), V1, L1+1);
- sial_setval(V1, v);
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) + 1);
+ sial_setval(v1, v);
}
break;
case POSTINCR: {
- sial_transfer(v=sial_newval(), V1, L1+1);
- sial_setval(V1, v);
- sial_transfer(v, V1, L1);
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) + 1);
+ sial_setval(v1, v);
+ sial_transfer(v, v1, unival(v1));
}
break;
case POSTDECR: {
- sial_transfer(v=sial_newval(), V1, L1-1);
- sial_setval(V1, v);
- sial_transfer(v, V1, L1);
+ V1;
+ sial_transfer(v=sial_newval(), v1,
+ unival(v1) - 1);
+ sial_setval(v1, v);
+ sial_transfer(v, v1, unival(v1));
}
break;
default: sial_rerror(&P1->pos, "Oops ops ! [%d]", top);
@@ -682,12 +703,14 @@ doop:
else {
/* if it's a Me-op then v is already set */
- if(top != o->op) { sial_setval(V1, v); }
- else {
-
- sial_setval(V1, V2);
+ V1;
+ if(top != o->op) {
+ sial_setval(v1, v);
+ } else {
+ sial_setval(v1, V2);
v=sial_cloneval(V2);
}
+
}
}
/* the result of a assignment if not an Lvalue_t */
17 years
kmem -p mapping and index
by Bob Montgomery
Dave,
We're working on a problem where two physical pages think they're mapped
to the same virtual page (one has been orphaned)
I wanted to see if any other cases occurred, so I wanted to use kmem -p
to dump all the page structs. But I got the lines like this:
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
ffff81012fbb7720 11c6fc000 ------- ----- 3 200000000000004
...
ffff81012fc8d3b8 120411000 ------- ----- 2 200000000000064
which led to the twisty passages of anonymous struct members, and gdb
nastiness, and datatype_info etc.
But the real key was that
MEMBER_OFFSET_INIT(page_mapping, "page", "mapping");
was failing because on our kernel, mapping is in an anonymous struct in
a union in the page struct.
When I figured out that the following would still work:
crash> gdb p &((struct page*)0x0).mapping
$4 = (struct address_space **) 0x18
I set about to writing a patch to find it the hard way by sending that
command to gdb and then parsing the result, blah, blah, blah. Imagine
my surprise when I looked for an example somewhere in crash and happened
upon anon_member_offset, doing exactly the same thing! That and a few
discovered macros and all I had to do was change the above to:
MEMBER_OFFSET_INIT(page_mapping, "page", "mapping");
if (INVALID_MEMBER(page_mapping))
ANON_MEMBER_OFFSET_INIT(page_mapping, "page","mapping");
So now, I can see that these two page structs have the same mapping and
offset, (and that this was the only case of it in my entire dump). I'm
so happy.
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
ffff81012fbb7720 11c6fc000 ffff81012a0993f1 11453246214 3 200000000000004
...
ffff81012fc8d3b8 120411000 ffff81012a0993f1 11453246214 2 200000000000064
Patch is attached. Any problem with doing it this way?
Thanks,
Bob Montgomery
17 years
waitq command does not work on RHEL5 and later (2.6.18 kernel)
by Alan Tyson
Hello,
I notice that struct __wait_queue changed somewhere around 2.6.15 and as
a result the waitq command fails because of the missing member "task"
which was replaced by the member "private" containing the same information.
> crash> waitq f75b9ac8
>
> waitq: invalid structure member offset: __wait_queue_task
> FILE: kernel.c LINE: 5429 FUNCTION: dump_waitq()
> << snipped >>
The attached patch fixes this, tested on RHEL4 and RHEL5 i686 only.
Regards,
Alan Tyson, HP.
--- kernel.c.orig 2007-10-30 15:51:54.000000000 +0000
+++ kernel.c 2007-11-06 10:12:25.000000000 +0000
@@ -390,8 +390,12 @@ kernel_init()
STRUCT_SIZE_INIT(__wait_queue, "__wait_queue");
if (VALID_STRUCT(__wait_queue)) {
- MEMBER_OFFSET_INIT(__wait_queue_task,
- "__wait_queue", "task");
+ if (MEMBER_EXISTS("__wait_queue", "task"))
+ MEMBER_OFFSET_INIT(__wait_queue_task,
+ "__wait_queue", "task");
+ else
+ MEMBER_OFFSET_INIT(__wait_queue_task,
+ "__wait_queue", "private");
MEMBER_OFFSET_INIT(__wait_queue_head_task_list,
"__wait_queue_head", "task_list");
MEMBER_OFFSET_INIT(__wait_queue_task_list,
17 years
[PATCH] display information about "struct page" on SPARSEMEM.
by Ken'ichi Ohmichi
Hi Dave,
This patch fixes the problem that the crash utility cannot display
"struct page" information about SPARSEMEM (not SPARSEMEM_EXTREME) properly.
The symbol mem_section is defined as the pointer array in SPARSEMEM_EXTREME.
On the other hand, SPARSEMEM's one is defined as the array of structure
mem_section like the following:
linux-2.6.23/mm/sparse.c:18L
#ifdef CONFIG_SPARSEMEM_EXTREME
struct mem_section *mem_section[NR_SECTION_ROOTS]
____cacheline_internodealigned_in_smp;
#else
struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]
____cacheline_internodealigned_in_smp;
#endif
EXPORT_SYMBOL(mem_section);
The crash utility considers SPARSEMEM's one to be the pointer array,
but it is wrong. This patch fixes it.
The following results are this patch effects.
* Before applying this patch
crash> kmem -p
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
100 0 ------- ----- 0 0
120 1000 ------- ----- 0 0
140 2000 ------- ----- 0 0
160 3000 ------- ----- 0 0
180 4000 ------- ----- 0 0
1a0 5000 ------- ----- 0 0
1c0 6000 ------- ----- 0 0
1e0 7000 ------- ----- 0 0
200 8000 ------- ----- 0 0
[snip]
crash>
* After applying this patch
crash> kmem -p
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
c5000000 0 ------- ----- 1 400
c5000020 1000 ------- ----- 1 400
c5000040 2000 ------- ----- 1 400
c5000060 3000 ------- ----- 1 400
c5000080 4000 ------- ----- 1 400
c50000a0 5000 ------- ----- 1 400
c50000c0 6000 ------- ----- 1 400
c50000e0 7000 ------- ----- 1 400
c5000100 8000 ------- ----- 0 80000
[snip]
crash>
Thanks
Ken'ichi Ohmichi
---
Signed-off-by: Ken'ichi Ohmichi <oomichi(a)mxs.nes.nec.co.jp>
---
diff -rpuN crash-4.0-4.8.org/memory.c crash-4.0-4.8/memory.c
--- crash-4.0-4.8.org/memory.c 2007-10-31 11:49:16.000000000 +0900
+++ crash-4.0-4.8/memory.c 2007-11-01 10:28:15.000000000 +0900
@@ -12229,7 +12229,9 @@ nr_to_section(ulong nr)
addr = mem_sec[SECTION_NR_TO_ROOT(nr)] +
(nr & SECTION_ROOT_MASK()) * SIZE(mem_section);
else
- addr = mem_sec[0] + (nr & SECTION_ROOT_MASK()) * SIZE(mem_section);
+ addr = symbol_value("mem_section") +
+ (SECTIONS_PER_ROOT() * SECTION_NR_TO_ROOT(nr) +
+ (nr & SECTION_ROOT_MASK())) * SIZE(mem_section);
if (!IS_KVADDR(addr))
return 0;
_
17 years