mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
commit
c7e1e49c7e
@ -95,8 +95,6 @@ std::string JsStackInfo::BuildMethodTrace(Method *method, uint32_t pcOffset, Las
|
||||
data.push_back('?');
|
||||
}
|
||||
data.append(")\n");
|
||||
LOG_ECMA(DEBUG) << "stack: " << data << "\nfileName: " << pandaFile->GetJSPandaFileDesc()
|
||||
<< "\nrecordName: " << method->GetRecordNameStr();
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,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, bool& isReplaces)
|
||||
{
|
||||
if (row < 1 || col < 1) {
|
||||
LOG_ECMA(ERROR) << "SourceMap find failed, line: " << row << ", column: " << col;
|
||||
@ -211,6 +211,7 @@ MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targe
|
||||
int32_t right = static_cast<int32_t>(targetMap.afterPos_.size()) - 1;
|
||||
int32_t res = 0;
|
||||
if (row > targetMap.afterPos_[targetMap.afterPos_.size() - 1].afterRow) {
|
||||
isReplaces = false;
|
||||
return MappingInfo { row + 1, col + 1};
|
||||
}
|
||||
while (right - left >= 0) {
|
||||
@ -345,14 +346,19 @@ bool SourceMap::TranslateUrlPositionBySourceMap(std::string& url, int& line, int
|
||||
url = tmp;
|
||||
return true;
|
||||
}
|
||||
bool isReplaces = true;
|
||||
bool ret = false;
|
||||
auto iterData = sourceMaps_.find(url);
|
||||
if (iterData != sourceMaps_.end()) {
|
||||
if (iterData->second == nullptr) {
|
||||
LOG_ECMA(ERROR) << "Extract mappings failed, url: " << url;
|
||||
return false;
|
||||
}
|
||||
url = tmp;
|
||||
return GetLineAndColumnNumbers(line, column, *(iterData->second));
|
||||
ret = GetLineAndColumnNumbers(line, column, *(iterData->second), isReplaces);
|
||||
if (isReplaces) {
|
||||
url = tmp;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
auto iter = mappings_.find(url);
|
||||
if (iter != mappings_.end()) {
|
||||
@ -368,20 +374,23 @@ bool SourceMap::TranslateUrlPositionBySourceMap(std::string& url, int& line, int
|
||||
}
|
||||
ExtractSourceMapData(mappings.substr(FLAG_MAPPINGS_LEN, mappings.size() - FLAG_MAPPINGS_LEN - 1), modularMap);
|
||||
sourceMaps_.emplace(url, modularMap);
|
||||
url = tmp;
|
||||
return GetLineAndColumnNumbers(line, column, *(modularMap));
|
||||
ret = GetLineAndColumnNumbers(line, column, *(modularMap), isReplaces);
|
||||
if (isReplaces) {
|
||||
url = tmp;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SourceMap::GetLineAndColumnNumbers(int& line, int& column, SourceMapData& targetMap)
|
||||
bool SourceMap::GetLineAndColumnNumbers(int& line, int& column, SourceMapData& targetMap, bool& isReplaces)
|
||||
{
|
||||
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, isReplaces);
|
||||
#else
|
||||
mapInfo = Find(line - offSet, column, targetMap);
|
||||
mapInfo = Find(line - offSet, column, targetMap, isReplaces);
|
||||
#endif
|
||||
if (mapInfo.row == 0 || mapInfo.col == 0) {
|
||||
return false;
|
||||
|
@ -81,9 +81,9 @@ 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, bool& isReplaces);
|
||||
void GetPosInfo(const std::string& temp, int32_t start, std::string& line, std::string& column);
|
||||
bool GetLineAndColumnNumbers(int& line, int& column, SourceMapData& targetMap);
|
||||
bool GetLineAndColumnNumbers(int& line, int& column, SourceMapData& targetMap, bool& isReplaces);
|
||||
uint32_t Base64CharToInt(char charCode);
|
||||
friend class SourceMapFriend;
|
||||
#if defined(PANDA_TARGET_OHOS)
|
||||
|
@ -167,9 +167,9 @@ public:
|
||||
sourceMap.ExtractSourceMapData(allmappings, curMapData);
|
||||
}
|
||||
|
||||
MappingInfo Find(int32_t row, int32_t col, const SourceMapData &targetMap)
|
||||
MappingInfo Find(int32_t row, int32_t col, const SourceMapData &targetMap, bool& isReplaces)
|
||||
{
|
||||
return sourceMap.Find(row, col, targetMap);
|
||||
return sourceMap.Find(row, col, targetMap, isReplaces);
|
||||
}
|
||||
|
||||
void ExtractKeyInfo(const std::string &aSourceMap, std::vector<std::string> &sourceKeyInfo)
|
||||
@ -197,9 +197,9 @@ public:
|
||||
return sourceMap.TranslateUrlPositionBySourceMap(url, line, column);
|
||||
}
|
||||
|
||||
bool GetLineAndColumnNumbers(int &line, int &column, SourceMapData &targetMap)
|
||||
bool GetLineAndColumnNumbers(int &line, int &column, SourceMapData &targetMap, bool& isReplaces)
|
||||
{
|
||||
return sourceMap.GetLineAndColumnNumbers(line, column, targetMap);
|
||||
return sourceMap.GetLineAndColumnNumbers(line, column, targetMap, isReplaces);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -383,13 +383,16 @@ HWTEST_F_L0(SourceMapTest, FindTest)
|
||||
SourceMapFriend sourceMapFriend;
|
||||
SourceMapData targetMap;
|
||||
MappingInfo mappingInfo;
|
||||
bool isReplaces = true;
|
||||
|
||||
mappingInfo = sourceMapFriend.Find(0, 1, targetMap);
|
||||
mappingInfo = sourceMapFriend.Find(0, 1, targetMap, isReplaces);
|
||||
EXPECT_EQ(mappingInfo.row, 0);
|
||||
EXPECT_EQ(mappingInfo.col, 0);
|
||||
mappingInfo = sourceMapFriend.Find(1, 1, targetMap);
|
||||
EXPECT_TRUE(isReplaces);
|
||||
mappingInfo = sourceMapFriend.Find(1, 1, targetMap, isReplaces);
|
||||
EXPECT_EQ(mappingInfo.row, 0);
|
||||
EXPECT_EQ(mappingInfo.col, 0);
|
||||
EXPECT_TRUE(isReplaces);
|
||||
|
||||
std::vector<SourceMapInfo> afterPos;
|
||||
SourceMapInfo info;
|
||||
@ -401,17 +404,20 @@ HWTEST_F_L0(SourceMapTest, FindTest)
|
||||
info.namesVal = 1;
|
||||
afterPos.push_back(info);
|
||||
targetMap.afterPos_ = afterPos;
|
||||
mappingInfo = sourceMapFriend.Find(3, 3, targetMap);
|
||||
mappingInfo = sourceMapFriend.Find(3, 3, targetMap, isReplaces);
|
||||
EXPECT_EQ(mappingInfo.row, 2);
|
||||
EXPECT_EQ(mappingInfo.col, 2);
|
||||
EXPECT_TRUE(isReplaces);
|
||||
|
||||
mappingInfo = sourceMapFriend.Find(3, 2, targetMap);
|
||||
mappingInfo = sourceMapFriend.Find(3, 2, targetMap, isReplaces);
|
||||
EXPECT_EQ(mappingInfo.row, 2);
|
||||
EXPECT_EQ(mappingInfo.col, 2);
|
||||
EXPECT_TRUE(isReplaces);
|
||||
|
||||
mappingInfo = sourceMapFriend.Find(2, 2, targetMap);
|
||||
mappingInfo = sourceMapFriend.Find(2, 2, targetMap, isReplaces);
|
||||
EXPECT_EQ(mappingInfo.row, 2);
|
||||
EXPECT_EQ(mappingInfo.col, 2);
|
||||
EXPECT_TRUE(isReplaces);
|
||||
}
|
||||
|
||||
HWTEST_F_L0(SourceMapTest, ExtractKeyInfoTest)
|
||||
@ -487,26 +493,30 @@ HWTEST_F_L0(SourceMapTest, GetLineAndColumnNumbersTest)
|
||||
info.namesVal = 1;
|
||||
afterPos.push_back(info);
|
||||
targetMap.afterPos_ = afterPos;
|
||||
bool isReplaces = true;
|
||||
|
||||
int line = 1;
|
||||
int column = 1;
|
||||
bool result = sourceMapFriend.GetLineAndColumnNumbers(line, column, targetMap);
|
||||
bool result = sourceMapFriend.GetLineAndColumnNumbers(line, column, targetMap, isReplaces);
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(line, 2);
|
||||
EXPECT_EQ(column, 2);
|
||||
EXPECT_TRUE(isReplaces);
|
||||
|
||||
line = 5;
|
||||
column = 5;
|
||||
result = sourceMapFriend.GetLineAndColumnNumbers(line, column, targetMap);
|
||||
result = sourceMapFriend.GetLineAndColumnNumbers(line, column, targetMap, isReplaces);
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(line, 5);
|
||||
EXPECT_EQ(column, 5);
|
||||
EXPECT_FALSE(isReplaces);
|
||||
|
||||
line = 99;
|
||||
column = 99;
|
||||
result = sourceMapFriend.GetLineAndColumnNumbers(line, column, targetMap);
|
||||
result = sourceMapFriend.GetLineAndColumnNumbers(line, column, targetMap, isReplaces);
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(line, 99);
|
||||
EXPECT_EQ(column, 99);
|
||||
EXPECT_FALSE(isReplaces);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user