Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,78 @@
#include <node.h>
#include <v8.h>
using v8::Context;
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::Value;
void TriggerReport(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
node::TriggerNodeReport(
isolate, "FooMessage", "BarTrigger", std::string(), Local<Value>());
}
void TriggerReportNoIsolate(const FunctionCallbackInfo<Value>& args) {
node::TriggerNodeReport(static_cast<Isolate*>(nullptr),
"FooMessage",
"BarTrigger",
std::string(),
Local<Value>());
}
void TriggerReportEnv(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
node::TriggerNodeReport(
node::GetCurrentEnvironment(isolate->GetCurrentContext()),
"FooMessage",
"BarTrigger",
std::string(),
Local<Value>());
}
void TriggerReportNoEnv(const FunctionCallbackInfo<Value>& args) {
node::TriggerNodeReport(static_cast<node::Environment*>(nullptr),
"FooMessage",
"BarTrigger",
std::string(),
Local<Value>());
}
void TriggerReportNoContext(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
context->Exit();
if (isolate->GetCurrentContext().IsEmpty()) {
node::TriggerNodeReport(
isolate, "FooMessage", "BarTrigger", std::string(), Local<Value>());
}
// Restore current context to avoid crashing in Context::Scope in
// SpinEventLoop.
context->Enter();
}
void TriggerReportNewContext(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = Context::New(isolate);
Context::Scope context_scope(context);
node::TriggerNodeReport(
isolate, "FooMessage", "BarTrigger", std::string(), Local<Value>());
}
void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "triggerReport", TriggerReport);
NODE_SET_METHOD(exports, "triggerReportNoIsolate", TriggerReportNoIsolate);
NODE_SET_METHOD(exports, "triggerReportEnv", TriggerReportEnv);
NODE_SET_METHOD(exports, "triggerReportNoEnv", TriggerReportNoEnv);
NODE_SET_METHOD(exports, "triggerReportNoContext", TriggerReportNoContext);
NODE_SET_METHOD(exports, "triggerReportNewContext", TriggerReportNewContext);
}
NODE_MODULE(NODE_GYP_MODULE_NAME, init)

View File

@ -0,0 +1,9 @@
{
'targets': [
{
'target_name': 'binding',
'sources': [ 'binding.cc' ],
'includes': ['../common.gypi'],
}
]
}

View File

@ -0,0 +1,53 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
const path = require('path');
const helper = require('../../common/report.js');
const tmpdir = require('../../common/tmpdir');
const binding = path.resolve(__dirname, `./build/${common.buildType}/binding`);
const addon = require(binding);
function myAddonMain(method, { hasContext, hasEnv }) {
tmpdir.refresh();
process.report.directory = tmpdir.path;
addon[method]();
const reports = helper.findReports(process.pid, tmpdir.path);
assert.strictEqual(reports.length, 1);
const report = reports[0];
helper.validate(report, [
['header.event', 'FooMessage'],
['header.trigger', 'BarTrigger'],
]);
const content = require(report);
// Check that the javascript stack is present.
if (hasContext) {
assert.strictEqual(content.javascriptStack.stack.findIndex((frame) => frame.match('myAddonMain')), 0);
} else {
assert.strictEqual(content.javascriptStack.message, 'No stack.');
}
if (hasEnv) {
assert.strictEqual(content.header.threadId, 0);
} else {
assert.strictEqual(content.header.threadId, null);
}
}
const methods = [
['triggerReport', true, true],
['triggerReportNoIsolate', false, false],
['triggerReportEnv', true, true],
['triggerReportNoEnv', false, false],
['triggerReportNoContext', false, false],
['triggerReportNewContext', true, false],
];
for (const [method, hasContext, hasEnv] of methods) {
myAddonMain(method, { hasContext, hasEnv });
}