mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-10-07 00:13:56 +00:00
fix bug
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IASOZ1 Signed-off-by: rentangyu <rentangyu@huawei.com>
This commit is contained in:
parent
0b7980d988
commit
88c0f05c37
@ -157,7 +157,7 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
if (isModular_) {
|
||||
auto iter = sourceMaps_.find(key);
|
||||
if (iter != sourceMaps_.end()) {
|
||||
sourceInfo = GetSourceInfo(line, column, *(iter->second));
|
||||
sourceInfo = GetSourceInfo(line, column, *(iter->second), key);
|
||||
} else if (key.rfind(".js") != std::string::npos) {
|
||||
ans = ans + temp + "\n";
|
||||
continue;
|
||||
@ -170,7 +170,7 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
continue;
|
||||
}
|
||||
ExtractSourceMapData(curSourceMap, nonModularMap_);
|
||||
sourceInfo = GetSourceInfo(line, column, *nonModularMap_);
|
||||
sourceInfo = GetSourceInfo(line, column, *nonModularMap_, key);
|
||||
}
|
||||
if (sourceInfo.empty()) {
|
||||
continue;
|
||||
@ -297,7 +297,7 @@ void SourceMap::ExtractSourceMapData(const std::string& allmappings, std::shared
|
||||
curMapData->mappings_.shrink_to_fit();
|
||||
}
|
||||
|
||||
MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targetMap)
|
||||
MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targetMap, const std::string& key)
|
||||
{
|
||||
if (row < 1 || col < 1 || targetMap.afterPos_.empty() || targetMap.sources_[0].empty()) {
|
||||
return MappingInfo {0, 0, ""};
|
||||
@ -308,10 +308,8 @@ MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targe
|
||||
int32_t left = 0;
|
||||
int32_t right = static_cast<int32_t>(targetMap.afterPos_.size()) - 1;
|
||||
int32_t res = 0;
|
||||
std::string sources = targetMap.sources_[0].substr(REAL_SOURCE_INDEX,
|
||||
targetMap.sources_[0].size() - REAL_SOURCE_SIZE - 1);
|
||||
if (row > targetMap.afterPos_[targetMap.afterPos_.size() - 1].afterRow) {
|
||||
return MappingInfo { row + 1, col + 1, sources };
|
||||
return MappingInfo { row + 1, col + 1, key };
|
||||
}
|
||||
while (right - left >= 0) {
|
||||
int32_t mid = (right + left) / 2;
|
||||
@ -323,6 +321,8 @@ MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targe
|
||||
left = mid + 1;
|
||||
}
|
||||
}
|
||||
std::string sources = targetMap.sources_[0].substr(REAL_SOURCE_INDEX,
|
||||
targetMap.sources_[0].size() - REAL_SOURCE_SIZE - 1);
|
||||
auto pos = sources.find(WEBPACK);
|
||||
if (pos != std::string::npos) {
|
||||
sources.replace(pos, sizeof(WEBPACK) - 1, "");
|
||||
@ -464,15 +464,15 @@ bool SourceMap::VlqRevCode(const std::string& vStr, std::vector<int32_t>& ans)
|
||||
};
|
||||
|
||||
std::string SourceMap::GetSourceInfo(const std::string& line, const std::string& column,
|
||||
const SourceMapData& targetMap)
|
||||
const SourceMapData& targetMap, const std::string& key)
|
||||
{
|
||||
int32_t offSet = 0;
|
||||
std::string sourceInfo;
|
||||
MappingInfo mapInfo;
|
||||
#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
|
||||
mapInfo = Find(StringToInt(line) - offSet + OFFSET_PREVIEW, StringToInt(column), targetMap);
|
||||
mapInfo = Find(StringToInt(line) - offSet + OFFSET_PREVIEW, StringToInt(column), targetMap, key);
|
||||
#else
|
||||
mapInfo = Find(StringToInt(line) - offSet, StringToInt(column), targetMap);
|
||||
mapInfo = Find(StringToInt(line) - offSet, StringToInt(column), targetMap, key);
|
||||
#endif
|
||||
if (mapInfo.row == 0 || mapInfo.col == 0) {
|
||||
return "";
|
||||
@ -535,9 +535,9 @@ bool SourceMap::GetLineAndColumnNumbers(int& line, int& column, SourceMapData& t
|
||||
int32_t offSet = 0;
|
||||
MappingInfo mapInfo;
|
||||
#if defined(WINDOWS_PLATFORM) || defined(MAC_PLATFORM)
|
||||
mapInfo = Find(line - offSet + OFFSET_PREVIEW, column, targetMap);
|
||||
mapInfo = Find(line - offSet + OFFSET_PREVIEW, column, targetMap, url);
|
||||
#else
|
||||
mapInfo = Find(line - offSet, column, targetMap);
|
||||
mapInfo = Find(line - offSet, column, targetMap, url);
|
||||
#endif
|
||||
if (mapInfo.row == 0 || mapInfo.col == 0) {
|
||||
return false;
|
||||
|
@ -89,10 +89,11 @@ private:
|
||||
void ExtractKeyInfo(const std::string& sourceMap, std::vector<std::string>& sourceKeyInfo);
|
||||
std::vector<std::string> HandleMappings(const std::string& mapping);
|
||||
bool VlqRevCode(const std::string& vStr, std::vector<int32_t>& ans);
|
||||
MappingInfo Find(int32_t row, int32_t col, const SourceMapData& targetMap);
|
||||
MappingInfo Find(int32_t row, int32_t col, const SourceMapData& targetMap, const std::string& key);
|
||||
void GetPosInfo(const std::string& temp, int32_t start, std::string& line, std::string& column);
|
||||
std::string GetRelativePath(const std::string& sources);
|
||||
std::string GetSourceInfo(const std::string& line, const std::string& column, const SourceMapData& targetMap);
|
||||
std::string GetSourceInfo(const std::string& line, const std::string& column,
|
||||
const SourceMapData& targetMap, const std::string& key);
|
||||
|
||||
private:
|
||||
bool isModular_ = true;
|
||||
|
@ -154,12 +154,12 @@ HWTEST_F(SourceMapTest, JsEnv_SourceMap_0800, Function | MediumTest | Level1)
|
||||
int32_t row = 0;
|
||||
int32_t col = 1;
|
||||
SourceMapData targetMap;
|
||||
auto info = modSourceMap->Find(row, col, targetMap);
|
||||
auto info = modSourceMap->Find(row, col, targetMap, "");
|
||||
EXPECT_TRUE(info.sources.empty());
|
||||
|
||||
row = 1;
|
||||
col = 0;
|
||||
info = modSourceMap->Find(row, col, targetMap);
|
||||
info = modSourceMap->Find(row, col, targetMap, "");
|
||||
EXPECT_TRUE(info.sources.empty());
|
||||
GTEST_LOG_(INFO) << "JsEnv_SourceMap_0800 end";
|
||||
}
|
||||
@ -188,7 +188,7 @@ HWTEST_F(SourceMapTest, JsEnv_SourceMap_0900, Function | MediumTest | Level1)
|
||||
targetMap.afterPos_.emplace_back(mapInfo);
|
||||
}
|
||||
}
|
||||
auto info = modSourceMap->Find(row, col, targetMap);
|
||||
auto info = modSourceMap->Find(row, col, targetMap, "");
|
||||
EXPECT_STREQ(info.sources.c_str(), "");
|
||||
GTEST_LOG_(INFO) << "JsEnv_SourceMap_0900 end";
|
||||
}
|
||||
@ -217,7 +217,7 @@ HWTEST_F(SourceMapTest, JsEnv_SourceMap_1000, Function | MediumTest | Level1)
|
||||
targetMap.afterPos_.emplace_back(mapInfo);
|
||||
}
|
||||
}
|
||||
auto info = modSourceMap->Find(row, col, targetMap);
|
||||
auto info = modSourceMap->Find(row, col, targetMap, "");
|
||||
EXPECT_STREQ(info.sources.c_str(), "");
|
||||
GTEST_LOG_(INFO) << "JsEnv_SourceMap_1000 end";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user