From ff4df6b6001ac7fd30103b469d0a076021f533c2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sat, 20 May 2023 19:41:12 -0700 Subject: [internal] Show the file path to the calling function from JS --- src/bun.js/scripts/generate-classes.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/bun.js/scripts/generate-classes.ts') diff --git a/src/bun.js/scripts/generate-classes.ts b/src/bun.js/scripts/generate-classes.ts index e8c4eeaa9..ff6954753 100644 --- a/src/bun.js/scripts/generate-classes.ts +++ b/src/bun.js/scripts/generate-classes.ts @@ -818,6 +818,17 @@ JSC_DEFINE_CUSTOM_SETTER(${symbolName( JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject); + #ifdef BUN_DEBUG + /** View the file name of the JS file that called this function + * from a debugger */ + SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm); + const char* fileName = sourceOrigin.string().utf8().data(); + static const char* lastFileName = nullptr; + if (lastFileName != fileName) { + lastFileName = fileName; + } + #endif + return ${symbolName(typeName, proto[name].fn)}(thisObject->wrapped(), lexicalGlobalObject, callFrame); } `); -- cgit v1.2.3