mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
deps: V8: cherry-pick 25902244ad1a
Original commit message:
[api] add line breaks to the output of Message::PrintCurrentStackTrace
Previously this prints the stack trace without line breaks and it
can be difficult to read. This also affects
--abort-on-uncaught-exception. This patch adds line breaks to the
output to improve readability.
Change-Id: I4c44b529f8c829329f784b0859b1d13c9ec56838
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4925009
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Cr-Commit-Position: refs/heads/main@{#90360}
Refs: https://github.com/v8/v8/commit/25902244ad1aa5ad7c7e5c85d6b0afae4e878536
PR-URL: https://github.com/nodejs/node/pull/50156
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This commit is contained in:
1 parent
35b160e6a3
commit
f72cbb7e02
3 files changed
+48
-1
No files matched your search
+1
-1
@@ -36,7 +36,7 @@
|
||||
|
||||
# Reset this number to 0 on major V8 upgrades.
|
||||
# Increment by one for each non-official patch applied to deps/v8.
|
||||
'v8_embedder_string': '-node.19',
|
||||
'v8_embedder_string': '-node.20',
|
||||
|
||||
##### V8 defaults for Node.js #####
|
||||
|
||||
|
||||
Vendored
+1
@@ -2451,6 +2451,7 @@ void Isolate::PrintCurrentStackTrace(std::ostream& out) {
|
||||
for (int i = 0; i < frames->length(); ++i) {
|
||||
Handle<CallSiteInfo> frame(CallSiteInfo::cast(frames->get(i)), this);
|
||||
SerializeCallSiteInfo(this, frame, &builder);
|
||||
if (i != frames->length() - 1) builder.AppendCharacter('\n');
|
||||
}
|
||||
|
||||
Handle<String> stack_trace = builder.Finish().ToHandleChecked();
|
||||
|
||||
Vendored
+46
@@ -31,6 +31,7 @@
|
||||
#include <csignal>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "test/cctest/cctest.h"
|
||||
@@ -4869,6 +4870,51 @@ TEST(MessageGetSourceLine) {
|
||||
});
|
||||
}
|
||||
|
||||
void GetCurrentStackTrace(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
std::stringstream ss;
|
||||
v8::Message::PrintCurrentStackTrace(args.GetIsolate(), ss);
|
||||
std::string str = ss.str();
|
||||
args.GetReturnValue().Set(v8_str(str.c_str()));
|
||||
}
|
||||
|
||||
THREADED_TEST(MessagePrintCurrentStackTrace) {
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
|
||||
templ->Set(isolate, "getCurrentStackTrace",
|
||||
v8::FunctionTemplate::New(isolate, GetCurrentStackTrace));
|
||||
LocalContext context(nullptr, templ);
|
||||
|
||||
v8::ScriptOrigin origin = v8::ScriptOrigin(isolate, v8_str("test"), 0, 0);
|
||||
v8::Local<v8::String> script = v8_str(
|
||||
"function c() {\n"
|
||||
" return getCurrentStackTrace();\n"
|
||||
"}\n"
|
||||
"function b() {\n"
|
||||
" return c();\n"
|
||||
"}\n"
|
||||
"function a() {\n"
|
||||
" return b();\n"
|
||||
"}\n"
|
||||
"a();");
|
||||
v8::Local<v8::Value> stack_trace =
|
||||
v8::Script::Compile(context.local(), script, &origin)
|
||||
.ToLocalChecked()
|
||||
->Run(context.local())
|
||||
.ToLocalChecked();
|
||||
|
||||
CHECK(stack_trace->IsString());
|
||||
v8::String::Utf8Value stack_trace_value(isolate,
|
||||
stack_trace.As<v8::String>());
|
||||
std::string stack_trace_string(*stack_trace_value);
|
||||
std::string expected(
|
||||
"c (test:2:10)\n"
|
||||
"b (test:5:10)\n"
|
||||
"a (test:8:10)\n"
|
||||
"test:10:1");
|
||||
CHECK_EQ(stack_trace_string, expected);
|
||||
}
|
||||
|
||||
THREADED_TEST(GetSetProperty) {
|
||||
LocalContext context;
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
|
||||
Reference in new issue
Block a user