FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Crash Utility

 
 
LinkBack Thread Tools
 
Old 01-24-2011, 08:35 AM
Lai Jiangshan
 
Default crash-trace-command: add sanity check for init_offsets()

Kernel are changed frequently, add checking for in case the structs are changed
and avoid to do something wrong.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/extensions/trace.c b/extensions/trace.c
index d100869..4247bfa 100755
--- a/extensions/trace.c
+++ b/extensions/trace.c
@@ -136,10 +136,17 @@ static int write_and_check(int fd, void *data, size_t size)
#define PATH_MAX 4096
#endif

-static void init_offsets(void)
-{
-#define init_offset(struct, member)
- koffset(struct, member) = MEMBER_OFFSET(#struct, #member);
+static int init_offsets(void)
+{
+#define init_offset(struct, member) do {
+ koffset(struct, member) = MEMBER_OFFSET(#struct, #member);
+ if (koffset(struct, member) < 0) {
+ fprintf(fp, "failed to init the offset, struct:"
+ #struct ", member:" #member);
+ return -1;
+ }
+ } while (0)
+

init_offset(trace_array, buffer);
init_offset(tracer, name);
@@ -183,6 +190,8 @@ static void init_offsets(void)
init_offset(ftrace_event_field, offset);
init_offset(ftrace_event_field, size);
init_offset(ftrace_event_field, is_signed);
+
+ return 0;
#undef init_offset
}

@@ -480,7 +489,8 @@ static int ftrace_init(void)
if (!try_get_symbol_data("nr_cpu_ids", sizeof(int), &nr_cpu_ids))
nr_cpu_ids = 1;

- init_offsets();
+ if (init_offsets() < 0)
+ return -1;
print_offsets();

if (ftrace_int_global_trace() < 0)

--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
 

Thread Tools




All times are GMT. The time now is 06:23 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org