Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report: misc cleanup #25597

Merged
merged 5 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,45 @@ void PerProcessOptions::CheckOptions(std::vector<std::string>* errors) {
void PerIsolateOptions::CheckOptions(std::vector<std::string>* errors) {
per_env->CheckOptions(errors);
#ifdef NODE_REPORT
if (!report_directory.empty() && !per_env->experimental_report)
if (per_env->experimental_report)
return;

if (!report_directory.empty()) {
errors->push_back("--diagnostic-report-directory option is valid only when "
"--experimental-report is set");
if (!report_filename.empty() && !per_env->experimental_report)
}

if (!report_filename.empty()) {
errors->push_back("--diagnostic-report-filename option is valid only when "
"--experimental-report is set");
if (!report_signal.empty() && !per_env->experimental_report)
}

if (!report_signal.empty()) {
errors->push_back("--diagnostic-report-signal option is valid only when "
"--experimental-report is set");
if (report_on_fatalerror && !per_env->experimental_report)
}

if (report_on_fatalerror) {
errors->push_back(
"--diagnostic-report-on-fatalerror option is valid only when "
"--experimental-report is set");
if (report_on_signal && !per_env->experimental_report)
}

if (report_on_signal) {
errors->push_back("--diagnostic-report-on-signal option is valid only when "
"--experimental-report is set");
if (report_uncaught_exception && !per_env->experimental_report)
}

if (report_uncaught_exception) {
errors->push_back(
"--diagnostic-report-uncaught-exception option is valid only when "
"--experimental-report is set");
if (report_verbose && !per_env->experimental_report)
}

if (report_verbose) {
errors->push_back("--diagnostic-report-verbose option is valid only when "
"--experimental-report is set");
}
#endif // NODE_REPORT
}

Expand Down
37 changes: 10 additions & 27 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ std::string TriggerNodeReport(Isolate* isolate,

// Obtain the current time and the pid (platform dependent)
TIME_TYPE tm_struct;
PID_TYPE pid;
LocalTime(&tm_struct);
pid = uv_os_getpid();
uv_pid_t pid = uv_os_getpid();
// Determine the required report filename. In order of priority:
// 1) supplied on API 2) configured on startup 3) default generated
if (!name.empty()) {
Expand Down Expand Up @@ -224,7 +223,7 @@ static void WriteNodeReport(Isolate* isolate,
Local<String> stackstr,
TIME_TYPE* tm_struct) {
std::ostringstream buf;
PID_TYPE pid = uv_os_getpid();
uv_pid_t pid = uv_os_getpid();

// Save formatting for output stream.
std::ios old_state(nullptr);
Expand Down Expand Up @@ -749,36 +748,20 @@ static void PrintSystemInformation(JSONWriter* writer) {

writer->json_objectstart("userLimits");
struct rlimit limit;
char buf[64];
std::string soft, hard;

for (size_t i = 0; i < arraysize(rlimit_strings); i++) {
if (getrlimit(rlimit_strings[i].id, &limit) == 0) {
if (limit.rlim_cur == RLIM_INFINITY) {
if (limit.rlim_cur == RLIM_INFINITY)
soft = std::string("unlimited");
} else {
#if defined(_AIX) || defined(__sun)
snprintf(buf, sizeof(buf), "%ld", limit.rlim_cur);
soft = std::string(buf);
#elif defined(__linux__) && !defined(__GLIBC__)
snprintf(buf, sizeof(buf), "%ld", limit.rlim_cur);
soft = std::string(buf);
#else
snprintf(buf, sizeof(buf), "%16" PRIu64, limit.rlim_cur);
soft = std::string(soft);
#endif
}
if (limit.rlim_max == RLIM_INFINITY) {
else
soft = std::to_string(limit.rlim_cur);

if (limit.rlim_max == RLIM_INFINITY)
hard = std::string("unlimited");
} else {
#ifdef _AIX
snprintf(buf, sizeof(buf), "%lu", limit.rlim_max);
hard = std::string(buf);
#else
snprintf(buf, sizeof(buf), "%llu", limit.rlim_max);
hard = std::string(buf);
#endif
}
else
hard = std::to_string(limit.rlim_max);

writer->json_objectstart(rlimit_strings[i].description);
writer->json_keyvalue("soft", soft);
writer->json_keyvalue("hard", hard);
Expand Down
2 changes: 0 additions & 2 deletions src/node_report.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ namespace report {

#ifdef _WIN32
typedef SYSTEMTIME TIME_TYPE;
typedef DWORD PID_TYPE;
#define PATHSEP "\\"
#else // UNIX, OSX
typedef struct tm TIME_TYPE;
typedef pid_t PID_TYPE;
#define PATHSEP "/"
#endif

Expand Down
8 changes: 1 addition & 7 deletions src/node_report_utils.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#include <v8.h>
#include "env.h"
#include "node_internals.h"
#include "node_options.h"
#include "node_report.h"
#include "util.h"
#include "v8.h"

namespace report {

Expand Down Expand Up @@ -232,8 +227,7 @@ void WalkHandle(uv_handle_t* h, void* arg) {
if (h->type == UV_TCP || h->type == UV_NAMED_PIPE || h->type == UV_TTY ||
h->type == UV_UDP || h->type == UV_POLL) {
uv_os_fd_t fd_v;
uv_os_fd_t* fd = &fd_v;
int rc = uv_fileno(h, fd);
int rc = uv_fileno(h, &fd_v);
// uv_os_fd_t is an int on Unix and HANDLE on Windows.
#ifndef _WIN32
if (rc == 0) {
Expand Down