From: Satoru MORIYA <satoru.moriya.br@hitachi.com>
To: "Discussion list for crash utility usage,
maintenance and development" <crash-utility@redhat.com>
Cc: yumiko.sugita.yf@hitachi.com, systemtap@sources.redhat.com
Subject: Re: [Crash-utility] Re: [RFC] Crash extension for SystemTap
Date: Mon, 20 Aug 2007 13:42:00 -0000 [thread overview]
Message-ID: <46C92209.90608@hitachi.com> (raw)
In-Reply-To: <y0mejjq4mel.fsf@ton.toronto.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1142 bytes --]
Hi Frank,
Thank you for including the crash extension in systemtap tree.
And I'm sorry for delaying my reply for a long time.
> [...]I could not make it print data from a crash session running
> against the live kernel [...]
I'm Sorry, I didn't test my crash extension on x86_64.
Now I tested it on x86_64 and fixed bugs, so I think you can
use it on x86_64 architecture.
Changes:
- fix the way of calculating the offset of rchan in struct utt_trace
- fix the type of padding value in output_cpu_logs()
- fix the console messages
- don't make a directory and files if there's no data in relay buffer
I have tested this extention on the following systems:
* FC7,i386,kernel-2.6.22,systemtap-0.5.15,crash-4.0-4.5
* FC7,x86_64,kernel-2.6.21-1.3194.fc7,systemtap-0.5.15,crash-4.0-4.5
* FC7,x86_64,kernel-2.6.21-1.3194.fc7debug,systemtap-0.5.15,crash-4.0-4.5
* RHEL5,i386,kernel-2.6.18-8.el5,systemtap-0.5.15,crash-4.0-4.5
* RHEL5,ia64,kernel-2.6.18-8.el5,systemtap-0.5.15,crash-4.0-4.5
Best regards,
--
---
Satoru MORIYA
Linux Technology Center
Hitachi, Ltd., Systems Development Laboratory
E-mail: satoru.moriya.br@hitachi.com
[-- Attachment #2: staplog_fix.patch --]
[-- Type: text/plain, Size: 4814 bytes --]
Index: systemtap/staplog.c
===================================================================
--- systemtap.orig/staplog.c
+++ systemtap/staplog.c
@@ -48,9 +48,6 @@
#include <crash/defs.h>
-#define STPLOG_NO_MOD -1
-#define STPLOG_NO_SYM -2
-
struct rchan_offsets {
long subbuf_size;
long n_subbufs;
@@ -167,10 +164,35 @@ static void get_rchan_buf(int cpu, ulong
static ulong get_rchan_addr(ulong stp_utt_addr)
{
ulong stp_utt;
+ long offset;
readmem(stp_utt_addr, KVADDR, &stp_utt, sizeof(void*),
"stp_utt", FAULT_ON_ERROR);
- return (stp_utt + sizeof(int));
+
+ /*
+ * If we couldn't get the member offset of struct utt_trace.rchan,
+ * i.e. the debuginfo of the trace module isn't available, we use
+ * sizeof(long) as the offset instead. Currently struct utt_trace
+ * is defined as below:
+ *
+ * struct utt_trace {
+ * int trace_state;
+ * struct rchan *rchan;
+ * ...
+ * }
+ *
+ * Although the type of the preceding member is int, sizeof(long)
+ * is OK, because rchan is aligned with long size on both 32-bit
+ * and 64-bit environment. When the definision of struct utt_trace
+ * changed, we must check if this code is correct.
+ */
+ if ((offset = MEMBER_OFFSET("utt_trace", "rchan")) < 0) {
+ error(WARNING, "The debuginfo of the trace module hasn't been loaded. "
+ "You may not be able to retrieve the correct trace data.\n");
+ offset = sizeof(long);
+ }
+
+ return (stp_utt + (ulong)offset);
}
static int check_global_buffer(ulong rchan)
@@ -220,25 +242,15 @@ static void setup_global_data(char *modu
return;
}
-static void output_cpu_logs(char *filename)
+static void output_cpu_logs(char *dirname)
{
int i, max = 256;
struct per_cpu_data *pcd;
size_t n, idx, start, end, ready, len;
- unsigned padding;
+ size_t padding;
char fname[max + 1], *source;
DIR *dir;
- /* check and create log directory */
- dir = opendir(filename);
- if (dir) {
- closedir(dir);
- } else {
- if (mkdir(filename, S_IRWXU) < 0) {
- error(FATAL, "cannot create log directory '%s\n'", filename);
- }
- }
-
/* allocate subbuf memory */
subbuf = GETBUF(chan.subbuf_size);
if (!subbuf) {
@@ -257,6 +269,15 @@ static void output_cpu_logs(char *filena
adjust = 1;
}
ready = pcd->buf.subbufs_produced + adjust;
+ if (ready == 0) {
+ if (is_global == 1) {
+ error(WARNING, "There is no data in the relay buffer.\n");
+ break;
+ } else {
+ error(WARNING, "[cpu:%d]There is no data in the relay buffer.\n", i);
+ continue;
+ }
+ }
if (ready > chan.n_subbufs) {
start = ready;
@@ -266,13 +287,30 @@ static void output_cpu_logs(char *filena
end = ready;
}
/* print information */
- fprintf(fp, "--- generating 'cpu%d' ---\n", i);
+ if (is_global == 1) {
+ fprintf(fp, "--- generating 'global' ---\n");
+ } else {
+ fprintf(fp, "--- generating 'cpu%d' ---\n", i);
+ }
fprintf(fp, " subbufs ready on relayfs:%ld\n", (long)ready);
- fprintf(fp, " n_subbufs:%ld, read from:%ld to:%ld (offset:%ld)\n\n",
- (long)chan.n_subbufs, (long)start, (long)end, (long)pcd->buf.offset);
-
- /* create log file */
- snprintf(fname, max, "%s/cpu%d", filename, i);
+ fprintf(fp, " n_subbufs:%ld, read from:%ld to:%ld (offset:%ld)\n\n",
+ (long)chan.n_subbufs, (long)(start ? start - chan.n_subbufs : start),
+ (long)(start ? end - 1 - chan.n_subbufs : end - 1), (long)pcd->buf.offset);
+
+ /* create log dir and file */
+ dir = opendir(dirname);
+ if (dir) {
+ closedir(dir);
+ } else {
+ if (mkdir(dirname, S_IRWXU) < 0) {
+ error(FATAL, "cannot create log directory '%s\n'", dirname);
+ }
+ }
+ if (is_global == 1) {
+ snprintf(fname, max, "%s/global", dirname, i);
+ } else {
+ snprintf(fname, max, "%s/cpu%d", dirname, i);
+ }
outfp = fopen(fname, "w");
if (!outfp) {
error(FATAL, "cannot create log file '%s'\n", fname);
@@ -316,10 +354,10 @@ static void output_cpu_logs(char *filena
return;
}
-static void do_staplog(char *module, char *filename)
+static void do_staplog(char *module, char *dirname)
{
setup_global_data(module);
- output_cpu_logs(filename);
+ output_cpu_logs(dirname);
return;
}
@@ -328,12 +366,12 @@ void cmd_staplog(void)
int c;
char *module = NULL;
- char *filename = NULL;
+ char *dirname = NULL;
while ((c = getopt(argcnt, args, "o:")) != EOF) {
switch (c) {
case 'o':
- filename = optarg;
+ dirname = optarg;
break;
default:
argerrs++;
@@ -345,9 +383,9 @@ void cmd_staplog(void)
if (!module || argerrs)
cmd_usage(pc->curcmd, SYNOPSIS);
- if (filename == NULL && module != NULL)
- filename = module;
- do_staplog(module, filename);
+ if (dirname == NULL && module != NULL)
+ dirname = module;
+ do_staplog(module, dirname);
return;
}
next prev parent reply other threads:[~2007-08-20 5:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-23 11:46 Satoru MORIYA
2007-05-23 13:22 ` [Crash-utility] " Dave Anderson
2007-05-23 19:01 ` Frank Eigler
2007-05-24 0:54 ` Satoru MORIYA
2007-05-24 14:44 ` [Crash-utility] " Dave Anderson
2007-06-22 13:43 ` Satoru MORIYA
2007-06-25 16:55 ` Frank Ch. Eigler
2007-07-02 19:48 ` Frank Ch. Eigler
2007-08-20 13:42 ` Satoru MORIYA [this message]
2007-08-20 17:50 ` Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46C92209.90608@hitachi.com \
--to=satoru.moriya.br@hitachi.com \
--cc=crash-utility@redhat.com \
--cc=systemtap@sources.redhat.com \
--cc=yumiko.sugita.yf@hitachi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).