| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8441d1f commit a60090c
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | |
| 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | |
| 39 | - 'v8_embedder_string': '-node.6', | ||
| 39 | + 'v8_embedder_string': '-node.7', | ||
| 40 | 40 | ||
| 41 | 41 | ##### V8 defaults for Node.js ##### | |
| 42 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2503,6 +2503,7 @@ void Isolate::PrintCurrentStackTrace(std::ostream& out) { | |||
| 2503 | 2503 | for (int i = 0; i < frames->length(); ++i) { | |
| 2504 | 2504 | Handle<CallSiteInfo> frame(CallSiteInfo::cast(frames->get(i)), this); | |
| 2505 | 2505 | SerializeCallSiteInfo(this, frame, &builder); | |
| 2506 | + if (i != frames->length() - 1) builder.AppendCharacter('\n'); | ||
| 2506 | 2507 | } | |
| 2507 | 2508 | ||
| 2508 | 2509 | Handle<String> stack_trace = builder.Finish().ToHandleChecked(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,7 @@ | |||
| 31 | 31 | #include <csignal> | |
| 32 | 32 | #include <map> | |
| 33 | 33 | #include <memory> | |
| 34 | + #include <sstream> | ||
| 34 | 35 | #include <string> | |
| 35 | 36 | ||
| 36 | 37 | #include "test/cctest/cctest.h" | |
@@ -4926,6 +4927,51 @@ TEST(MessageGetSourceLine) { | |||
| 4926 | 4927 | }); | |
| 4927 | 4928 | } | |
| 4928 | 4929 | ||
| 4930 | + void GetCurrentStackTrace(const v8::FunctionCallbackInfo<v8::Value>& args) { | ||
| 4931 | + std::stringstream ss; | ||
| 4932 | + v8::Message::PrintCurrentStackTrace(args.GetIsolate(), ss); | ||
| 4933 | + std::string str = ss.str(); | ||
| 4934 | + args.GetReturnValue().Set(v8_str(str.c_str())); | ||
| 4935 | + } | ||
| 4936 | + | ||
| 4937 | + THREADED_TEST(MessagePrintCurrentStackTrace) { | ||
| 4938 | + v8::Isolate* isolate = CcTest::isolate(); | ||
| 4939 | + v8::HandleScope scope(isolate); | ||
| 4940 | + Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); | ||
| 4941 | + templ->Set(isolate, "getCurrentStackTrace", | ||
| 4942 | + v8::FunctionTemplate::New(isolate, GetCurrentStackTrace)); | ||
| 4943 | + LocalContext context(nullptr, templ); | ||
| 4944 | + | ||
| 4945 | + v8::ScriptOrigin origin = v8::ScriptOrigin(isolate, v8_str("test"), 0, 0); | ||
| 4946 | + v8::Local<v8::String> script = v8_str( | ||
| 4947 | + "function c() {\n" | ||
| 4948 | + " return getCurrentStackTrace();\n" | ||
| 4949 | + "}\n" | ||
| 4950 | + "function b() {\n" | ||
| 4951 | + " return c();\n" | ||
| 4952 | + "}\n" | ||
| 4953 | + "function a() {\n" | ||
| 4954 | + " return b();\n" | ||
| 4955 | + "}\n" | ||
| 4956 | + "a();"); | ||
| 4957 | + v8::Local<v8::Value> stack_trace = | ||
| 4958 | + v8::Script::Compile(context.local(), script, &origin) | ||
| 4959 | + .ToLocalChecked() | ||
| 4960 | + ->Run(context.local()) | ||
| 4961 | + .ToLocalChecked(); | ||
| 4962 | + | ||
| 4963 | + CHECK(stack_trace->IsString()); | ||
| 4964 | + v8::String::Utf8Value stack_trace_value(isolate, | ||
| 4965 | + stack_trace.As<v8::String>()); | ||
| 4966 | + std::string stack_trace_string(*stack_trace_value); | ||
| 4967 | + std::string expected( | ||
| 4968 | + "c (test:2:10)\n" | ||
| 4969 | + "b (test:5:10)\n" | ||
| 4970 | + "a (test:8:10)\n" | ||
| 4971 | + "test:10:1"); | ||
| 4972 | + CHECK_EQ(stack_trace_string, expected); | ||
| 4973 | + } | ||
| 4974 | + | ||
| 4929 | 4975 | THREADED_TEST(GetSetProperty) { | |
| 4930 | 4976 | LocalContext context; | |
| 4931 | 4977 | v8::Isolate* isolate = context->GetIsolate(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments