完善执行ark buffer的时候的mmap标签

Signed-off-by: shaoyijiang <shaoyijiang@huawei.com>
Change-Id: I7c5c35af1f6c192a1a88a8dc816d54e4e06f8884
This commit is contained in:
shaoyijiang 2024-02-26 07:00:42 +00:00
parent 761a13f082
commit 8c2508e71c
4 changed files with 47 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -456,6 +456,10 @@ std::optional<CodeInfo> TranslateByteCodePc(uintptr_t realPc, const std::vector<
bool ArkParseJsFrameInfo(uintptr_t byteCodePc, uintptr_t mapBase, uintptr_t loadOffset,
uint8_t *data, uint64_t dataSize, JsFunction *jsFunction)
{
if (data == nullptr) {
LOG_ECMA(ERROR) << "JSpandafile buffer from dfx is nullptr.";
return false;
}
loadOffset = loadOffset % PageSize();
auto pf = panda_file::OpenPandaFileFromSecureMemory(data, dataSize);
CString fileName = "";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -145,7 +145,8 @@ std::shared_ptr<JSPandaFile> JSPandaFileManager::LoadJSPandaFile(JSThread *threa
}
}
auto pf = panda_file::OpenPandaFileFromMemory(buffer, size);
CString tag = ModulePathHelper::ParseFileNameToVMAName(filename);
auto pf = panda_file::OpenPandaFileFromMemory(buffer, size, tag.c_str());
if (pf == nullptr) {
LOG_ECMA(ERROR) << "open file " << filename << " error";
return nullptr;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -590,4 +590,37 @@ void ModulePathHelper::ParseCrossModuleFile(const JSPandaFile *jsPandaFile, CStr
requestPath = outEntryPoint.substr(0, index) + requestPath.substr(pos);
}
}
CString ModulePathHelper::ParseFileNameToVMAName(const CString &filename)
{
CString tag = VMA_NAME_ARKTS_CODE;
size_t pos = CString::npos;
if (filename.empty()) {
return tag;
}
if (filename.find(EXT_NAME_JS) != CString::npos) {
pos = filename.find(EXT_NAME_Z_SO);
if (pos == CString::npos) {
return tag;
}
CString moduleName = filename.substr(0, pos);
pos = moduleName.rfind(PathHelper::POINT_TAG);
if (pos == CString::npos) {
return tag + PathHelper::COLON_TAG + filename;
}
CString realModuleName = moduleName.substr(pos + 1);
CString realFileName = realModuleName;
std::transform(realFileName.begin(), realFileName.end(), realFileName.begin(), ::tolower);
CString file = PREFIX_LIB + realFileName + EXT_NAME_Z_SO + PathHelper::SLASH_TAG + realModuleName + EXT_NAME_JS;
return tag + PathHelper::COLON_TAG + file;
}
if (filename.find(EXT_NAME_ABC) != CString::npos) {
CString file = filename.substr(BUNDLE_INSTALL_PATH_LEN);
return tag + PathHelper::COLON_TAG + file;
}
return tag;
}
} // namespace panda::ecmascript

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@ -64,10 +64,12 @@ public:
static constexpr char EXT_NAME_TS[] = ".ts";
static constexpr char EXT_NAME_JS[] = ".js";
static constexpr char EXT_NAME_JSON[] = ".json";
static constexpr char EXT_NAME_Z_SO[] = ".z.so";
static constexpr char PREFIX_BUNDLE[] = "@bundle:";
static constexpr char PREFIX_MODULE[] = "@module:";
static constexpr char PREFIX_PACKAGE[] = "@package:";
static constexpr char PREFIX_ETS[] = "ets/";
static constexpr char PREFIX_LIB[] = "lib";
static constexpr char REQUIRE_NAITVE_MODULE_PREFIX[] = "@native:";
static constexpr char REQUIRE_NAPI_OHOS_PREFIX[] = "@ohos:";
static constexpr char REQUIRE_NAPI_APP_PREFIX[] = "@app:";
@ -82,6 +84,7 @@ public:
static constexpr char PREVIEW_OF_ACROSS_HAP_FLAG[] = "[preview]";
static constexpr char PREVIER_TEST_DIR[] = ".test";
static constexpr char PHYCICAL_FILE_PATH[] = "/src/main";
static constexpr char VMA_NAME_ARKTS_CODE[] = "ArkTS Code";
static constexpr size_t MAX_PACKAGE_LEVEL = 1;
static constexpr size_t SEGMENTS_LIMIT_TWO = 2;
@ -135,6 +138,7 @@ public:
* Before: data/storage/el1/bundle/moduleName/ets/modules.abc
* After: bundle/moduleName
*/
static CString ParseFileNameToVMAName(const CString &filename);
inline static std::string ParseHapPath(const CString &baseFileName)
{
CString bundleSubInstallName(BUNDLE_SUB_INSTALL_PATH);