From 814fa40ae904b173217beb9631f54dc0f9b196ea Mon Sep 17 00:00:00 2001 From: Richard Chamberlain Date: Fri, 4 Nov 2016 15:17:55 +0000 Subject: [PATCH 1/2] Add support for nodereport on AIX 1. features.h and execinfo.h do not exist 2. backtrace() API is not available, native stacks disabled 3. ru_utime.tv_usec is int (same as OSX) 4. ulimit RLIMIT_MEMLOCK is not available 5. PRIu64 macro is not available --- src/node_report.cc | 29 ++++++++++++++++++++++++++++- src/node_report.h | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/node_report.cc b/src/node_report.cc index 0848182..019abf3 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -29,7 +29,9 @@ #include #include #include +#ifndef _AIX #include +#endif #include #endif @@ -580,6 +582,16 @@ void PrintNativeStack(FILE* fp) { } } } +#elif _AIX +/******************************************************************************* + * Function to print a native stack backtrace - AIX + * + ******************************************************************************/ +void PrintNativeStack(FILE* fp) { + fprintf(fp, "\n================================================================================"); + fprintf(fp, "\n==== Native Stack Trace ========================================================\n\n"); + fprintf(fp, "Native stack trace not supported on AIX\n"); +} #else /******************************************************************************* * Function to print a native stack backtrace - Linux/OSX @@ -683,7 +695,7 @@ static void PrintResourceUsage(FILE* fp) { struct rusage stats; fprintf(fp, "\nProcess total resource usage:"); if (getrusage(RUSAGE_SELF, &stats) == 0) { -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(_AIX) fprintf(fp, "\n User mode CPU: %ld.%06d secs", stats.ru_utime.tv_sec, stats.ru_utime.tv_usec); fprintf(fp, "\n Kernel mode CPU: %ld.%06d secs", stats.ru_stime.tv_sec, stats.ru_stime.tv_usec); #else @@ -698,8 +710,13 @@ static void PrintResourceUsage(FILE* fp) { #ifdef RUSAGE_THREAD fprintf(fp, "\n\nEvent loop thread resource usage:"); if (getrusage(RUSAGE_THREAD, &stats) == 0) { +#if defined(__APPLE__) || defined(_AIX) + fprintf(fp, "\n User mode CPU: %ld.%06d secs", stats.ru_utime.tv_sec, stats.ru_utime.tv_usec); + fprintf(fp, "\n Kernel mode CPU: %ld.%06d secs", stats.ru_stime.tv_sec, stats.ru_stime.tv_usec); +#else fprintf(fp, "\n User mode CPU: %ld.%06ld secs", stats.ru_utime.tv_sec, stats.ru_utime.tv_usec); fprintf(fp, "\n Kernel mode CPU: %ld.%06ld secs", stats.ru_stime.tv_sec, stats.ru_stime.tv_usec); +#endif fprintf(fp, "\n Filesystem activity: %ld reads %ld writes", stats.ru_inblock, stats.ru_oublock); } #endif @@ -748,7 +765,9 @@ const static struct { {"core file size (blocks) ", RLIMIT_CORE}, {"data seg size (kbytes) ", RLIMIT_DATA}, {"file size (blocks) ", RLIMIT_FSIZE}, +#ifndef _AIX {"max locked memory (bytes) ", RLIMIT_MEMLOCK}, +#endif {"max memory size (kbytes) ", RLIMIT_RSS}, {"open files ", RLIMIT_NOFILE}, {"stack size (bytes) ", RLIMIT_STACK}, @@ -766,12 +785,20 @@ const static struct { if (limit.rlim_cur == RLIM_INFINITY) { fprintf(fp, " unlimited"); } else { +#ifdef _AIX + fprintf(fp, "%16ld", limit.rlim_cur); +#else fprintf(fp, "%16" PRIu64, limit.rlim_cur); +#endif } if (limit.rlim_max == RLIM_INFINITY) { fprintf(fp, " unlimited\n"); } else { +#ifdef _AIX + fprintf(fp, "%16ld\n", limit.rlim_max); +#else fprintf(fp, "%16" PRIu64 "\n", limit.rlim_max); +#endif } } } diff --git a/src/node_report.h b/src/node_report.h index d952a48..624b2b1 100644 --- a/src/node_report.h +++ b/src/node_report.h @@ -5,7 +5,7 @@ #ifndef _WIN32 #include #include -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(_AIX) #include #endif #endif From f08d7c215153ba2f9b6c91d7decb1d3833ec5cc6 Mon Sep 17 00:00:00 2001 From: Richard Chamberlain Date: Wed, 9 Nov 2016 10:46:47 +0000 Subject: [PATCH 2/2] Add AIX to list of supported platforms in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb990d4..d54e587 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ It includes JavaScript and native stack traces, heap statistics, platform information and resource usage etc. With the report enabled, reports can be triggered on unhandled exceptions, fatal errors, signals and calls to a JavaScript API. The module supports Node.js v4, v6 and v7 -on Linux, MacOS and Windows. +on Linux, MacOS, Windows and AIX. Usage: