From e485fb6878ba217c42f3f7cc909db7582581ef52 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jun 25 2015 13:17:19 +0000 Subject: import crash-trace-command-2.0-9.aa7a --- diff --git a/.crash-trace-command.metadata b/.crash-trace-command.metadata new file mode 100644 index 0000000..60d2250 --- /dev/null +++ b/.crash-trace-command.metadata @@ -0,0 +1 @@ +b92c7a1f6b69e5a2e3142b68c76f46e0ebcf204e SOURCES/crash-trace-command-2.0.tar.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a4b556 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/crash-trace-command-2.0.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 0e7897f..0000000 --- a/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 - -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/ARM64.patch b/SOURCES/ARM64.patch new file mode 100644 index 0000000..ff7abd0 --- /dev/null +++ b/SOURCES/ARM64.patch @@ -0,0 +1,13 @@ +--- crash-trace-command-2.0/Makefile.orig ++++ crash-trace-command-2.0/Makefile +@@ -22,6 +22,10 @@ ifeq ($(shell arch), s390) + TARGET=S390 + TARGET_CFLAGS= + endif ++ifeq ($(shell arch), aarch64) ++ TARGET=ARM64 ++ TARGET_CFLAGS= ++endif + + INCDIR=/usr/include/crash + diff --git a/SOURCES/initialize_trace_dat.patch b/SOURCES/initialize_trace_dat.patch new file mode 100644 index 0000000..6b1a25b --- /dev/null +++ b/SOURCES/initialize_trace_dat.patch @@ -0,0 +1,11 @@ +--- crash-trace-command-2.0/trace.c.orig ++++ crash-trace-command-2.0/trace.c +@@ -1373,7 +1373,7 @@ static void ftrace_dump(int argc, char * + if (dump_symbols || dump_meta_data || argc - optind > 1) + cmd_usage(pc->curcmd, SYNOPSIS); + else { +- char *trace_dat; ++ char *trace_dat = "trace.dat"; + int fd; + + if (argc - optind == 0) diff --git a/SOURCES/linux_3.10_support.patch b/SOURCES/linux_3.10_support.patch new file mode 100644 index 0000000..d520492 --- /dev/null +++ b/SOURCES/linux_3.10_support.patch @@ -0,0 +1,152 @@ +--- crash-trace-command-2.0/trace.c.orig ++++ crash-trace-command-2.0/trace.c +@@ -26,9 +26,21 @@ static int nr_cpu_ids; + */ + static int lockless_ring_buffer; + static int per_cpu_buffer_sizes; ++/* ++ * global and encapsulated current_trace are both supported ++ */ ++static int encapsulated_current_trace; ++/* ++ * trace_buffer is supported ++ */ ++static int trace_buffer_available; + + #define koffset(struct, member) struct##_##member##_offset + ++static int koffset(trace_array, current_trace); ++static int koffset(trace_array, trace_buffer); ++static int koffset(trace_array, max_buffer); ++static int koffset(trace_buffer, buffer); + static int koffset(trace_array, buffer); + static int koffset(tracer, name); + +@@ -85,6 +97,8 @@ struct ring_buffer_per_cpu { + }; + + static ulong global_trace; ++static ulong global_trace_buffer; ++static ulong global_max_buffer; + static ulong global_ring_buffer; + static unsigned global_pages; + static struct ring_buffer_per_cpu *global_buffers; +@@ -144,8 +158,16 @@ static int init_offsets(void) + } \ + } while (0) + ++ if (encapsulated_current_trace) ++ init_offset(trace_array, current_trace); + +- init_offset(trace_array, buffer); ++ if (trace_buffer_available) { ++ init_offset(trace_array, trace_buffer); ++ init_offset(trace_array, max_buffer); ++ init_offset(trace_buffer, buffer); ++ } else { ++ init_offset(trace_array, buffer); ++ } + init_offset(tracer, name); + + if (MEMBER_EXISTS("ring_buffer_per_cpu", "nr_pages")) { +@@ -400,8 +422,13 @@ out_fail: + + static int ftrace_int_global_trace(void) + { +- read_value(global_ring_buffer, global_trace, trace_array, buffer); +- read_value(global_pages, global_ring_buffer, ring_buffer, pages); ++ if (trace_buffer_available) { ++ global_trace_buffer = global_trace + koffset(trace_array, trace_buffer); ++ read_value(global_ring_buffer, global_trace_buffer, trace_buffer, buffer); ++ } else { ++ read_value(global_ring_buffer, global_trace, trace_array, buffer); ++ read_value(global_pages, global_ring_buffer, ring_buffer, pages); ++ } + + global_buffers = calloc(sizeof(*global_buffers), nr_cpu_ids); + if (global_buffers == NULL) +@@ -420,12 +447,17 @@ out_fail: + + static int ftrace_int_max_tr_trace(void) + { +- read_value(max_tr_ring_buffer, max_tr_trace, trace_array, buffer); ++ if (trace_buffer_available) { ++ global_max_buffer = global_trace + koffset(trace_array, max_buffer); ++ read_value(max_tr_ring_buffer, global_max_buffer, trace_buffer, buffer); ++ } else { ++ read_value(max_tr_ring_buffer, max_tr_trace, trace_array, buffer); + +- if (!max_tr_ring_buffer) +- return 0; ++ if (!max_tr_ring_buffer) ++ return 0; + +- read_value(max_tr_pages, max_tr_ring_buffer, ring_buffer, pages); ++ read_value(max_tr_pages, max_tr_ring_buffer, ring_buffer, pages); ++ } + + max_tr_buffers = calloc(sizeof(*max_tr_buffers), nr_cpu_ids); + if (max_tr_buffers == NULL) +@@ -449,7 +481,12 @@ static int ftrace_init_current_tracer(vo + char tmp[128]; + + /* Get current tracer name */ +- read_value(addr, current_trace, POINTER_SYM, POINTER); ++ if (encapsulated_current_trace) { ++ read_value(addr, global_trace, trace_array, current_trace); ++ } else { ++ read_value(addr, current_trace, POINTER_SYM, POINTER); ++ } ++ + read_value(addr, addr, tracer, name); + read_string(addr, tmp, 128); + +@@ -471,19 +508,33 @@ static int ftrace_init(void) + struct syment *sym_current_trace; + + sym_global_trace = symbol_search("global_trace"); +- sym_max_tr_trace = symbol_search("max_tr"); + sym_ftrace_events = symbol_search("ftrace_events"); +- sym_current_trace = symbol_search("current_trace"); + +- if (sym_global_trace == NULL || sym_max_tr_trace == NULL +- || sym_ftrace_events == NULL +- || sym_current_trace == NULL) ++ if (sym_global_trace == NULL || sym_ftrace_events == NULL) + return -1; + + global_trace = sym_global_trace->value; +- max_tr_trace = sym_max_tr_trace->value; + ftrace_events = sym_ftrace_events->value; +- current_trace = sym_current_trace->value; ++ ++ if (MEMBER_EXISTS("trace_array", "current_trace")) { ++ encapsulated_current_trace = 1; ++ } else { ++ sym_current_trace = symbol_search("current_trace"); ++ if (sym_current_trace == NULL) ++ return -1; ++ ++ current_trace = sym_current_trace->value; ++ } ++ ++ if (MEMBER_EXISTS("trace_array", "trace_buffer")) { ++ trace_buffer_available = 1; ++ } else { ++ sym_max_tr_trace = symbol_search("max_tr"); ++ if (sym_max_tr_trace == NULL) ++ return -1; ++ ++ max_tr_trace = sym_max_tr_trace->value; ++ } + + if (!try_get_symbol_data("nr_cpu_ids", sizeof(int), &nr_cpu_ids)) + nr_cpu_ids = 1; +@@ -1453,6 +1504,7 @@ static void ftrace_show(int argc, char * + if ((file = popen(trace_cmd, "r"))) { + ret = fread(buf, 1, sizeof(buf), file); + buf[ret] = 0; ++ pclose(file); + } + if (!strstr(buf, "trace-cmd version")) { + if (env_trace_cmd) diff --git a/SOURCES/ppc64le.patch b/SOURCES/ppc64le.patch new file mode 100644 index 0000000..b787e66 --- /dev/null +++ b/SOURCES/ppc64le.patch @@ -0,0 +1,13 @@ +--- crash-trace-command-2.0/Makefile.orig ++++ crash-trace-command-2.0/Makefile +@@ -6,6 +6,10 @@ ifeq ($(shell arch), ppc64) + TARGET=PPC64 + TARGET_CFLAGS=-m64 + endif ++ifeq ($(shell arch), ppc64le) ++ TARGET=PPC64 ++ TARGET_CFLAGS=-m64 ++endif + ifeq ($(shell arch), ia64) + TARGET=IA64 + TARGET_CFLAGS= diff --git a/SOURCES/replace_obsolete_init_and_fini.patch b/SOURCES/replace_obsolete_init_and_fini.patch new file mode 100644 index 0000000..1357429 --- /dev/null +++ b/SOURCES/replace_obsolete_init_and_fini.patch @@ -0,0 +1,31 @@ +--- crash-trace-command-2.0/trace.c.orig ++++ crash-trace-command-2.0/trace.c +@@ -1536,23 +1535,21 @@ static struct command_table_entry comman + + static int ftrace_initialized; + +-int _init(void) ++void __attribute__((constructor)) ++trace_init(void) + { + if (ftrace_init() < 0) +- return 0; ++ return; + + ftrace_initialized = 1; + register_extension(command_table); +- +- return 1; + } + +-int _fini(void) ++void __attribute__((destructor)) ++trace_fini(void) + { + if (ftrace_initialized) + ftrace_destroy(); +- +- return 1; + } + + #define TRACE_CMD_FILE_VERSION_STRING "6" diff --git a/SOURCES/sigsegv_on_calloc_failure.patch b/SOURCES/sigsegv_on_calloc_failure.patch new file mode 100644 index 0000000..580adac --- /dev/null +++ b/SOURCES/sigsegv_on_calloc_failure.patch @@ -0,0 +1,10 @@ +--- crash-trace-command-2.0/trace.c.orig ++++ crash-trace-command-2.0/trace.c +@@ -251,7 +251,6 @@ static int ftrace_init_pages(struct ring + + cpu_buffer->linear_pages = calloc(sizeof(ulong), nr_pages + 1); + if (cpu_buffer->linear_pages == NULL) { +- free(cpu_buffer->pages); + return -1; + } + diff --git a/SOURCES/trace_compiler_warnings.patch b/SOURCES/trace_compiler_warnings.patch new file mode 100644 index 0000000..904f4d0 --- /dev/null +++ b/SOURCES/trace_compiler_warnings.patch @@ -0,0 +1,46 @@ +--- crash-trace-command-2.0/trace.c.orig ++++ crash-trace-command-2.0/trace.c +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + + static int verbose = 0; + +@@ -892,7 +893,7 @@ out_fail: + + static int ftrace_init_event_type(ulong call, struct event_type *aevent_type) + { +- ulong fields_head; ++ ulong fields_head = 0; + + if (ftrace_get_event_type_fields(call, &fields_head) < 0) + return -1; +@@ -1443,6 +1444,8 @@ static void ftrace_show(int argc, char * + int fd; + FILE *file; + size_t ret; ++ size_t nitems __attribute__ ((__unused__)); ++ char *unused __attribute__ ((__unused__)); + + /* check trace-cmd */ + if (env_trace_cmd) +@@ -1465,7 +1468,7 @@ static void ftrace_show(int argc, char * + } + + /* dump trace.dat to the temp file */ +- mktemp(tmp); ++ unused = mktemp(tmp); + fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (trace_cmd_data_output(fd) < 0) + goto out; +@@ -1478,7 +1481,7 @@ static void ftrace_show(int argc, char * + ret = fread(buf, 1, sizeof(buf), file); + if (ret == 0) + break; +- fwrite(buf, 1, ret, fp); ++ nitems = fwrite(buf, 1, ret, fp); + } + pclose(file); + out: diff --git a/SPECS/crash-trace-command.spec b/SPECS/crash-trace-command.spec new file mode 100644 index 0000000..678435e --- /dev/null +++ b/SPECS/crash-trace-command.spec @@ -0,0 +1,115 @@ +# +# crash core analysis suite +# +Summary: Trace extension module for the crash utility +Name: crash-trace-command +Version: 2.0 +Release: 9%{?dist} +License: GPLv2 +Group: Development/Debuggers +Source: %{name}-%{version}.tar.gz +URL: http://people.redhat.com/anderson/extensions/%{name}-%{version}.tar.gz +# Vendor: Fujitsu Limited +# Packager: Qiao Nuohan +ExclusiveOS: Linux +ExclusiveArch: x86_64 %{ix86} ppc64 ia64 s390 s390x aarch64 ppc64le +Buildroot: %{_tmppath}/%{name}-root +BuildRequires: crash-devel zlib-devel lzo-devel snappy-devel +Requires: trace-cmd +Patch0: trace_compiler_warnings.patch +Patch1: replace_obsolete_init_and_fini.patch +Patch2: sigsegv_on_calloc_failure.patch +Patch3: initialize_trace_dat.patch +Patch4: ARM64.patch +Patch5: linux_3.10_support.patch +Patch6: ppc64le.patch + +%description +Command for reading ftrace data from a dumpfile. + +%prep +%setup -q -n %{name}-%{version} +%patch0 -p1 -b trace_compiler_warnings.patch +%patch1 -p1 -b replace_obsolete_init_and_fini.patch +%patch2 -p1 -b sigsegv_on_calloc_failure.patch +%patch3 -p1 -b initialize_trace_dat.patch +%patch4 -p1 -b ARM64.patch +%patch5 -p1 -b linux_3.10_support.patch +%patch6 -p1 -b ppc64le.patch + +%build +make + +%install +mkdir -p %{buildroot}%{_libdir}/crash/extensions/ +cp %{_builddir}/%{name}-%{version}/trace.so %{buildroot}%{_libdir}/crash/extensions/ + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +%{_libdir}/crash/extensions/trace.so +%doc COPYING + +%changelog +* Tue Sep 02 2014 Dave Anderson - 2.0-9 +- Add ppc64le support. + Resolves: rhbz#1123995 + +* Fri Jan 24 2014 Daniel Mach - 2.0-8 +- Mass rebuild 2014-01-24 + +* Fri Dec 27 2013 Daniel Mach - 2.0-7 +- Mass rebuild 2013-12-27 + +* Thu Dec 5 2013 Dave Anderson - 2.0-6 +- Add Linux 3.10 support. + Resolves: rhbz#863833 + +* Tue Nov 12 2013 Dave Anderson - 2.0-5 +- Add ARM64 support. + Resolves: rhbz#1028580 + +* Tue Aug 20 2013 Dave Anderson - 2.0-4 +- crash utility has added LZO and snappy compression in addition to zlib + +* Wed May 29 2013 Dave Anderson - 2.0-3 +- Replace obsolete _init() and _fini() functions. +- Fix possible segmentation violation on calloc() failure. +- Initialize trace_dat to avoid compiler warning. + +* Mon Nov 26 2012 Dave Anderson - 2.0-2 +- trace-cmd package required +- rpmlint cleanups to this file +- fix compiler warnings for trace.c + +* Wed Nov 21 2012 Qiao Nuohan - 2.0-1 +- update code + Resolves: rhbz#863833 + +* Wed Feb 8 2012 Dave Anderson - 1.0-4 +- Build with RPM_OPT_FLAGS. + Resolves: rhbz#729018 + +* Wed Jun 9 2010 Dave Anderson - 1.0-3 +- Remove trace_dump.patch, which requires a kernel later than + the RHEL6 base of 2.6.32. + Resolves: rbhz#601536 + +* Mon May 24 2010 Dave Anderson - 1.0-2 +- Fix for segmentation violation with "trace show -c cpu" command, + and add "trace dump -t" command. + Resolves: rbhz#592887 + +* Wed Dec 09 2009 Dave Anderson - 1.0-1.2 +- fix Makefile to account for s390 build +- change exclusive arch entry from i386 to {ix86} +- Resolves: rbhz#545564 + +* Tue Dec 08 2009 Dennis Gregorovic - 1.0-1.1 +- Rebuilt for RHEL 6 + +* Fri Sep 25 2009 Dave Anderson +- Initial crash-trace-command package +