From 23feaa56cf0762e7407ae896e42e9f921b10c7b0 Mon Sep 17 00:00:00 2001 From: Will Holen Date: Tue, 12 Nov 2019 16:26:29 -0800 Subject: [PATCH] Make debugger ScriptIDs per RuntimeModule rather than per filename Summary: When a filename (potentially with changes) is loaded multiple times, we keep multiple instances around but fail to alert the attached debugger about this. By coupling ScriptIDs to RuntimeModules rather than filenames, we can track multiple instances of the same name instead. Changelog: [Internal] Reviewed By: bestander Differential Revision: D18362052 fbshipit-source-id: 2147af32bc48c5fd2a2b080ea09dfa4133de7cf5 --- .../hermes/inspector/chrome/MessageConverters.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ReactCommon/hermes/inspector/chrome/MessageConverters.h b/ReactCommon/hermes/inspector/chrome/MessageConverters.h index e6460396954..b8a606b56bb 100644 --- a/ReactCommon/hermes/inspector/chrome/MessageConverters.h +++ b/ReactCommon/hermes/inspector/chrome/MessageConverters.h @@ -47,11 +47,16 @@ void setHermesLocation( hermesLoc.fileName = stripCachePrevention(chromeLoc.url.value()); } else if (chromeLoc.urlRegex.hasValue()) { const std::regex regex(stripCachePrevention(chromeLoc.urlRegex.value())); - for (const auto &fileName : parsedScripts) { - if (std::regex_match(fileName, regex)) { - hermesLoc.fileName = fileName; + auto it = parsedScripts.rbegin(); + + // We currently only support one physical breakpoint per location, so + // search backwards so that we find the latest matching file. + while (it != parsedScripts.rend()) { + if (std::regex_match(*it, regex)) { + hermesLoc.fileName = *it; break; } + it++; } } }