Skip to content

Commit

Permalink
report: rename location to trigger
Browse files Browse the repository at this point in the history
trigger more accurately describes the use of the field.
Previously, location was just the name of the C++ function
that called TriggerNodeReport().

PR-URL: #26386
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cjihrig authored and BridgeAR committed Mar 4, 2019
1 parent 3093617 commit 2908e63
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion doc/api/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ is provided below for reference.
{
"header": {
"event": "exception",
"location": "OnUncaughtException",
"trigger": "Exception",
"filename": "report.20181221.005011.8974.001.json",
"dumpEventTime": "2018-12-21T00:50:11Z",
"dumpEventTimeStamp": "1545371411331",
Expand Down
2 changes: 1 addition & 1 deletion src/node_errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ void OnFatalError(const char* location, const char* message) {
Environment* env = Environment::GetCurrent(isolate);
if (env == nullptr || env->isolate_data()->options()->report_on_fatalerror) {
report::TriggerNodeReport(
isolate, env, message, __func__, "", Local<String>());
isolate, env, message, "FatalError", "", Local<String>());
}
#endif // NODE_REPORT
fflush(stderr);
Expand Down
24 changes: 12 additions & 12 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ using v8::Value;
static void WriteNodeReport(Isolate* isolate,
Environment* env,
const char* message,
const char* location,
const char* trigger,
const std::string& filename,
std::ostream& out,
Local<String> stackstr,
Expand All @@ -79,7 +79,7 @@ static void PrintVersionInformation(JSONWriter* writer);
static void PrintJavaScriptStack(JSONWriter* writer,
Isolate* isolate,
Local<String> stackstr,
const char* location);
const char* trigger);
static void PrintNativeStack(JSONWriter* writer);
#ifndef _WIN32
static void PrintResourceUsage(JSONWriter* writer);
Expand All @@ -100,7 +100,7 @@ static std::atomic_int seq = {0}; // sequence number for report filenames
std::string TriggerNodeReport(Isolate* isolate,
Environment* env,
const char* message,
const char* location,
const char* trigger,
std::string name,
Local<String> stackstr) {
std::ostringstream oss;
Expand Down Expand Up @@ -178,7 +178,7 @@ std::string TriggerNodeReport(Isolate* isolate,
<< "Writing Node.js report to file: " << filename << std::endl;
}

WriteNodeReport(isolate, env, message, location, filename, *outstream,
WriteNodeReport(isolate, env, message, trigger, filename, *outstream,
stackstr, &tm_struct);

// Do not close stdout/stderr, only close files we opened.
Expand All @@ -194,22 +194,22 @@ std::string TriggerNodeReport(Isolate* isolate,
void GetNodeReport(Isolate* isolate,
Environment* env,
const char* message,
const char* location,
const char* trigger,
Local<String> stackstr,
std::ostream& out) {
// Obtain the current time and the pid (platform dependent)
TIME_TYPE tm_struct;
LocalTime(&tm_struct);
WriteNodeReport(
isolate, env, message, location, "", out, stackstr, &tm_struct);
isolate, env, message, trigger, "", out, stackstr, &tm_struct);
}

// Internal function to coordinate and write the various
// sections of the report to the supplied stream
static void WriteNodeReport(Isolate* isolate,
Environment* env,
const char* message,
const char* location,
const char* trigger,
const std::string& filename,
std::ostream& out,
Local<String> stackstr,
Expand All @@ -228,7 +228,7 @@ static void WriteNodeReport(Isolate* isolate,
writer.json_objectstart("header");

writer.json_keyvalue("event", message);
writer.json_keyvalue("location", location);
writer.json_keyvalue("trigger", trigger);
if (!filename.empty())
writer.json_keyvalue("filename", filename);
else
Expand Down Expand Up @@ -280,7 +280,7 @@ static void WriteNodeReport(Isolate* isolate,
writer.json_objectend();

// Report summary JavaScript stack backtrace
PrintJavaScriptStack(&writer, isolate, stackstr, location);
PrintJavaScriptStack(&writer, isolate, stackstr, trigger);

// Report native stack backtrace
PrintNativeStack(&writer);
Expand Down Expand Up @@ -372,12 +372,12 @@ static void PrintVersionInformation(JSONWriter* writer) {
static void PrintJavaScriptStack(JSONWriter* writer,
Isolate* isolate,
Local<String> stackstr,
const char* location) {
const char* trigger) {
writer->json_objectstart("javascriptStack");

std::string ss;
if ((!strcmp(location, "OnFatalError")) ||
(!strcmp(location, "Signal"))) {
if ((!strcmp(trigger, "FatalError")) ||
(!strcmp(trigger, "Signal"))) {
ss = "No stack.\nUnavailable.\n";
} else {
String::Utf8Value sv(isolate, stackstr);
Expand Down
4 changes: 2 additions & 2 deletions src/node_report.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ typedef struct tm TIME_TYPE;
std::string TriggerNodeReport(v8::Isolate* isolate,
node::Environment* env,
const char* message,
const char* location,
const char* trigger,
std::string name,
v8::Local<v8::String> stackstr);
void GetNodeReport(v8::Isolate* isolate,
node::Environment* env,
const char* message,
const char* location,
const char* trigger,
v8::Local<v8::String> stackstr,
std::ostream& out);

Expand Down
4 changes: 2 additions & 2 deletions test/common/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ function _validateContent(data) {

// Verify the format of the header section.
const header = report.header;
const headerFields = ['event', 'location', 'filename', 'dumpEventTime',
const headerFields = ['event', 'trigger', 'filename', 'dumpEventTime',
'dumpEventTimeStamp', 'processId', 'commandLine',
'nodejsVersion', 'wordSize', 'arch', 'platform',
'componentVersions', 'release', 'osName', 'osRelease',
'osVersion', 'osMachine', 'host', 'glibcVersionRuntime',
'glibcVersionCompiler'];
checkForUnknownFields(header, headerFields);
assert.strictEqual(typeof header.event, 'string');
assert.strictEqual(typeof header.location, 'string');
assert.strictEqual(typeof header.trigger, 'string');
assert(typeof header.filename === 'string' || header.filename === null);
assert.notStrictEqual(new Date(header.dumpEventTime).toString(),
'Invalid Date');
Expand Down

0 comments on commit 2908e63

Please sign in to comment.