refactor stl container

1. using runtime container instead of stl container
2. change debugger line amd column type to int32_t

issue: https://gitee.com/openharmony/ark_js_runtime/issues/I50NHW

Signed-off-by: wengchangcheng <wengchangcheng@huawei.com>
Change-Id: I0eb4651f17c6f6894f11de1ba904bcbe83a57db7
This commit is contained in:
wengchangcheng
2022-03-31 23:38:07 +08:00
parent 78c38d9a2b
commit 0b4981525d
70 changed files with 706 additions and 694 deletions
+8
View File
@@ -0,0 +1,8 @@
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)
UT/test262/启动应用/调试应用
+3 -3
View File
@@ -215,10 +215,10 @@ CString ErrorHelper::BuildNativeEcmaStackTrace(JSThread *thread)
}
data.push_back(':');
// line number and column number
auto callbackFunc = [&data](size_t line, size_t column) -> bool {
data += ToCString(static_cast<int>(line) + 1);
auto callbackFunc = [&data](int32_t line, int32_t column) -> bool {
data += ToCString(line + 1);
data.push_back(':');
data += ToCString(static_cast<int>(column) + 1);
data += ToCString(column + 1);
return true;
};
if (!debugExtractor->MatchWithOffset(callbackFunc, method->GetFileId(), frameHandler.GetBytecodeOffset())) {
+1 -1
View File
@@ -57,7 +57,7 @@ bool PassManager::CollectInfoOfPandaFile(const std::string &fileName, BytecodeTr
return false;
}
const JSPandaFile *jsPandaFile =
JSPandaFileManager::GetInstance()->LoadAotInfoFromPf(fileName, &(translateInfo->methodPcInfos));
JSPandaFileManager::GetInstance()->LoadAotInfoFromPf(fileName.c_str(), &(translateInfo->methodPcInfos));
if (jsPandaFile == nullptr) {
return false;
}
+5 -5
View File
@@ -222,11 +222,11 @@ void CpuProfiler::ParseMethodInfo(JSMethod *method, InterpretedFrameHandler fram
}
}
// line number
int lineNumber = 0;
int columnNumber = 0;
auto callbackFunc = [&](size_t line, size_t column) -> bool {
lineNumber = static_cast<int>(line) + 1;
columnNumber = static_cast<int>(column) + 1;
int32_t lineNumber = 0;
int32_t columnNumber = 0;
auto callbackFunc = [&](int32_t line, int32_t column) -> bool {
lineNumber = line + 1;
columnNumber = column + 1;
return true;
};
if (!debugExtractor->MatchWithOffset(callbackFunc, method->GetFileId(), frameHandler.GetBytecodeOffset())) {
+3 -3
View File
@@ -136,8 +136,8 @@ EcmaVM::EcmaVM(JSRuntimeOptions options)
if (!snapshotSerializeEnable_) {
snapshotDeserializeEnable_ = options_.IsSnapshotDeserializeEnabled();
}
snapshotFileName_ = options_.GetSnapshotFile();
frameworkAbcFileName_ = options_.GetFrameworkAbcFile();
snapshotFileName_ = options_.GetSnapshotFile().c_str();
frameworkAbcFileName_ = options_.GetFrameworkAbcFile().c_str();
options_.ParseAsmInterOption();
auto runtime = Runtime::GetCurrent();
@@ -583,7 +583,7 @@ void EcmaVM::RemoveFromNativePointerList(JSNativePointer *array)
}
// Do not support snapshot on windows
bool EcmaVM::VerifyFilePath(const std::string &filePath) const
bool EcmaVM::VerifyFilePath(const CString &filePath) const
{
#ifndef PANDA_TARGET_WINDOWS
if (filePath.size() > PATH_MAX) {
+3 -3
View File
@@ -412,7 +412,7 @@ private:
void InitializeEcmaScriptRunStat();
bool VerifyFilePath(const std::string &filePath) const;
bool VerifyFilePath(const CString &filePath) const;
void ClearBufferData();
@@ -454,8 +454,8 @@ private:
EcmaRuntimeStat *runtimeStat_ {nullptr};
// For framewrok file snapshot.
std::string snapshotFileName_;
std::string frameworkAbcFileName_;
CString snapshotFileName_;
CString frameworkAbcFileName_;
JSTaggedValue frameworkProgram_ {JSTaggedValue::Hole()};
const JSPandaFile *frameworkPandaFile_ {nullptr};
CMap<const JSPandaFile *, JSTaggedValue> cachedConstpools_ {};
+14 -13
View File
@@ -15,6 +15,7 @@
#include "ecmascript/jspandafile/debug_info_extractor.h"
#include "ecmascript/jspandafile/js_pandafile.h"
#include "libpandabase/utils/utf.h"
#include "libpandafile/class_data_accessor-inl.h"
#include "libpandafile/debug_data_accessor-inl.h"
@@ -33,9 +34,9 @@ static const char *GetStringFromConstantPool(const panda_file::File &pf, uint32_
return utf::Mutf8AsCString(pf.GetStringData(panda_file::File::EntityId(offset)).data);
}
DebugInfoExtractor::DebugInfoExtractor(const panda_file::File *pf)
DebugInfoExtractor::DebugInfoExtractor(const JSPandaFile *jsPandaFile)
{
Extract(pf);
Extract(jsPandaFile->GetPandaFile());
}
class LineNumberProgramProcessor {
@@ -50,7 +51,7 @@ public:
void Process()
{
auto opcode = ReadOpcode();
lnt_.push_back({state_.GetAddress(), state_.GetLine()});
lnt_.push_back({static_cast<int32_t>(state_.GetAddress()), static_cast<int32_t>(state_.GetLine())});
while (opcode != Opcode::END_SEQUENCE) {
switch (opcode) {
case Opcode::ADVANCE_LINE: {
@@ -200,7 +201,7 @@ private:
{
auto cn = state_.ReadULeb128();
state_.SetColumn(cn);
cnt_.push_back({state_.GetAddress(), state_.GetColumn()});
cnt_.push_back({static_cast<int32_t>(state_.GetAddress()), static_cast<int32_t>(state_.GetColumn())});
}
void HandleSpecialOpcode(LineNumberProgramItem::Opcode opcode)
@@ -213,7 +214,7 @@ private:
static_cast<int32_t>(adjustOpcode) % LineNumberProgramItem::LINE_RANGE + LineNumberProgramItem::LINE_BASE;
state_.AdvancePc(pcOffset);
state_.AdvanceLine(lineOffset);
lnt_.push_back({state_.GetAddress(), state_.GetLine()});
lnt_.push_back({static_cast<int32_t>(state_.GetAddress()), static_cast<int32_t>(state_.GetLine())});
}
LineProgramState state_;
@@ -296,27 +297,27 @@ const LocalVariableTable &DebugInfoExtractor::GetLocalVariableTable(panda_file::
return iter->second.localVariableTable;
}
const char *DebugInfoExtractor::GetSourceFile(panda_file::File::EntityId methodId) const
const CString &DebugInfoExtractor::GetSourceFile(panda_file::File::EntityId methodId) const
{
auto iter = methods_.find(methodId.GetOffset());
if (iter == methods_.end()) {
return "";
return CString("");
}
return iter->second.sourceFile.c_str();
return iter->second.sourceFile;
}
const char *DebugInfoExtractor::GetSourceCode(panda_file::File::EntityId methodId) const
const CString &DebugInfoExtractor::GetSourceCode(panda_file::File::EntityId methodId) const
{
auto iter = methods_.find(methodId.GetOffset());
if (iter == methods_.end()) {
return "";
return CString("");
}
return iter->second.sourceCode.c_str();
return iter->second.sourceCode;
}
std::vector<panda_file::File::EntityId> DebugInfoExtractor::GetMethodIdList() const
CVector<panda_file::File::EntityId> DebugInfoExtractor::GetMethodIdList() const
{
std::vector<panda_file::File::EntityId> list;
CVector<panda_file::File::EntityId> list;
for (const auto &method : methods_) {
list.push_back(panda_file::File::EntityId(method.first));
+19 -18
View File
@@ -16,41 +16,42 @@
#ifndef ECMASCRIPT_JSPANDAFILE_DEBUG_INFO_EXTRACTOR_H
#define ECMASCRIPT_JSPANDAFILE_DEBUG_INFO_EXTRACTOR_H
#include <vector>
#include <unordered_map>
#include "ecmascript/mem/c_containers.h"
#include "ecmascript/mem/c_string.h"
#include "ecmascript/common.h"
#include "libpandafile/file.h"
namespace panda::ecmascript {
class JSPandaFile;
struct LineTableEntry {
uint32_t offset;
size_t line;
int32_t line;
};
struct ColumnTableEntry {
uint32_t offset;
size_t column;
int32_t column;
};
using LineNumberTable = std::vector<LineTableEntry>;
using ColumnNumberTable = std::vector<ColumnTableEntry>;
using LineNumberTable = CVector<LineTableEntry>;
using ColumnNumberTable = CVector<ColumnTableEntry>;
/*
* LocalVariableInfo define in frontend, now only use name and regNumber:
* std::string name
* std::string type
* std::string typeSignature
* CString name
* CString type
* CString typeSignature
* int32_t regNumber
* uint32_t startOffset
* uint32_t endOffset
*/
using LocalVariableTable = std::unordered_map<std::string, int32_t>;
using LocalVariableTable = CUnorderedMap<CString, int32_t>;
// public for debugger
class PUBLIC_API DebugInfoExtractor {
public:
explicit DebugInfoExtractor(const panda_file::File *pf);
explicit DebugInfoExtractor(const JSPandaFile *jsPandaFile);
~DebugInfoExtractor() = default;
@@ -63,24 +64,24 @@ public:
const LocalVariableTable &GetLocalVariableTable(panda_file::File::EntityId methodId) const;
const char *GetSourceFile(panda_file::File::EntityId methodId) const;
const CString &GetSourceFile(panda_file::File::EntityId methodId) const;
const char *GetSourceCode(panda_file::File::EntityId methodId) const;
const CString &GetSourceCode(panda_file::File::EntityId methodId) const;
std::vector<panda_file::File::EntityId> GetMethodIdList() const;
CVector<panda_file::File::EntityId> GetMethodIdList() const;
private:
void Extract(const panda_file::File *pf);
struct MethodDebugInfo {
std::string sourceFile;
std::string sourceCode;
CString sourceFile;
CString sourceCode;
LineNumberTable lineNumberTable;
ColumnNumberTable columnNumberTable;
LocalVariableTable localVariableTable;
};
std::unordered_map<uint32_t, MethodDebugInfo> methods_;
CUnorderedMap<uint32_t, MethodDebugInfo> methods_;
};
} // namespace panda::ecmascript
+1 -1
View File
@@ -18,7 +18,7 @@
#include "ecmascript/jspandafile/program_object-inl.h"
namespace panda::ecmascript {
JSPandaFile::JSPandaFile(const panda_file::File *pf, const std::string &descriptor) : pf_(pf), desc_(descriptor)
JSPandaFile::JSPandaFile(const panda_file::File *pf, const CString &descriptor) : pf_(pf), desc_(descriptor)
{
ASSERT(pf_ != nullptr);
Initialize();
+6 -6
View File
@@ -35,10 +35,10 @@ namespace ecmascript {
class JSPandaFile {
public:
JSPandaFile(const panda_file::File *pf, const std::string &descriptor);
JSPandaFile(const panda_file::File *pf, const CString &descriptor);
~JSPandaFile();
const std::string &GetJSPandaFileDesc() const
const CString &GetJSPandaFileDesc() const
{
return desc_;
}
@@ -75,7 +75,7 @@ public:
return mainMethodIndex_;
}
const std::unordered_map<uint32_t, uint64_t> &GetConstpoolMap() const
const CUnorderedMap<uint32_t, uint64_t> &GetConstpoolMap() const
{
return constpoolMap_;
}
@@ -100,13 +100,13 @@ private:
void Initialize();
uint32_t constpoolIndex_ {0};
std::unordered_map<uint32_t, uint64_t> constpoolMap_;
CUnorderedMap<uint32_t, uint64_t> constpoolMap_;
uint32_t numMethods_ {0};
uint32_t mainMethodIndex_ {0};
JSMethod *methods_ {nullptr};
std::unordered_map<uint32_t, JSMethod *> methodMap_;
CUnorderedMap<uint32_t, JSMethod *> methodMap_;
const panda_file::File *pf_ {nullptr};
std::string desc_;
CString desc_;
bool isModule_ {false};
};
} // namespace ecmascript
@@ -21,7 +21,7 @@
#include "ecmascript/module/js_module_manager.h"
namespace panda::ecmascript {
bool JSPandaFileExecutor::ExecuteFromFile(JSThread *thread, const std::string &filename, std::string_view entryPoint,
bool JSPandaFileExecutor::ExecuteFromFile(JSThread *thread, const CString &filename, std::string_view entryPoint,
const std::vector<std::string> &args)
{
const JSPandaFile *jsPandaFile = JSPandaFileManager::GetInstance()->LoadJSPandaFile(filename);
@@ -49,7 +49,7 @@ bool JSPandaFileExecutor::ExecuteFromFile(JSThread *thread, const std::string &f
bool JSPandaFileExecutor::ExecuteFromBuffer(JSThread *thread, const void *buffer, size_t size,
std::string_view entryPoint, const std::vector<std::string> &args,
const std::string &filename)
const CString &filename)
{
const JSPandaFile *jsPandaFile = JSPandaFileManager::GetInstance()->LoadJSPandaFile(filename, buffer, size);
if (jsPandaFile == nullptr) {
@@ -25,10 +25,10 @@
namespace panda::ecmascript {
class JSPandaFileExecutor {
public:
static bool ExecuteFromFile(JSThread *thread, const std::string &filename, std::string_view entryPoint,
static bool ExecuteFromFile(JSThread *thread, const CString &filename, std::string_view entryPoint,
const std::vector<std::string> &args);
static bool ExecuteFromBuffer(JSThread *thread, const void *buffer, size_t size, std::string_view entryPoint,
const std::vector<std::string> &args, const std::string &filename = "");
const std::vector<std::string> &args, const CString &filename = "");
private:
static bool Execute(JSThread *thread, const JSPandaFile *jsPandaFile, std::string_view entryPoint,
const std::vector<std::string> &args);
@@ -32,7 +32,7 @@ JSPandaFileManager::~JSPandaFileManager()
}
// generate aot info on host
const JSPandaFile *JSPandaFileManager::LoadAotInfoFromPf(const std::string &filename,
const JSPandaFile *JSPandaFileManager::LoadAotInfoFromPf(const CString &filename,
std::vector<MethodPcInfo> *methodPcInfos)
{
JSPandaFile *jsPandaFile = OpenJSPandaFile(filename);
@@ -45,7 +45,7 @@ const JSPandaFile *JSPandaFileManager::LoadAotInfoFromPf(const std::string &file
return jsPandaFile;
}
const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(const std::string &filename)
const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(const CString &filename)
{
ECMA_BYTRACE_NAME(BYTRACE_TAG_ARK, "JSPandaFileManager::LoadJSPandaFile");
const JSPandaFile *jsPandaFile = FindJSPandaFile(filename);
@@ -64,7 +64,7 @@ const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(const std::string &filena
return jsPandaFile;
}
const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(const std::string &filename, const void *buffer, size_t size)
const JSPandaFile *JSPandaFileManager::LoadJSPandaFile(const CString &filename, const void *buffer, size_t size)
{
if (buffer == nullptr || size == 0) {
return nullptr;
@@ -95,7 +95,7 @@ JSHandle<Program> JSPandaFileManager::GenerateProgram(EcmaVM *vm, const JSPandaF
return program;
}
const JSPandaFile *JSPandaFileManager::FindJSPandaFile(const std::string &filename)
const JSPandaFile *JSPandaFileManager::FindJSPandaFile(const CString &filename)
{
if (filename.empty()) {
return nullptr;
@@ -156,7 +156,7 @@ void JSPandaFileManager::DecreaseRefJSPandaFile(const JSPandaFile *jsPandaFile)
ReleaseJSPandaFile(jsPandaFile);
}
JSPandaFile *JSPandaFileManager::OpenJSPandaFile(const std::string &filename)
JSPandaFile *JSPandaFileManager::OpenJSPandaFile(const CString &filename)
{
auto pf = panda_file::OpenPandaFileOrZip(filename, panda_file::File::READ_WRITE);
if (pf == nullptr) {
@@ -168,7 +168,7 @@ JSPandaFile *JSPandaFileManager::OpenJSPandaFile(const std::string &filename)
return jsPandaFile;
}
JSPandaFile *JSPandaFileManager::NewJSPandaFile(const panda_file::File *pf, const std::string &desc)
JSPandaFile *JSPandaFileManager::NewJSPandaFile(const panda_file::File *pf, const CString &desc)
{
return new JSPandaFile(pf, desc);
}
@@ -191,7 +191,7 @@ tooling::ecmascript::JSPtExtractor *JSPandaFileManager::GetJSPtExtractor(const J
auto iter = extractors_.find(jsPandaFile);
if (iter == extractors_.end()) {
auto extractorPtr = std::make_unique<tooling::ecmascript::JSPtExtractor>(jsPandaFile->GetPandaFile());
auto extractorPtr = std::make_unique<tooling::ecmascript::JSPtExtractor>(jsPandaFile);
tooling::ecmascript::JSPtExtractor *extractor = extractorPtr.get();
extractors_[jsPandaFile] = std::move(extractorPtr);
return extractor;
@@ -200,7 +200,7 @@ tooling::ecmascript::JSPtExtractor *JSPandaFileManager::GetJSPtExtractor(const J
return iter->second.get();
}
const JSPandaFile *JSPandaFileManager::GenerateJSPandaFile(const panda_file::File *pf, const std::string &desc)
const JSPandaFile *JSPandaFileManager::GenerateJSPandaFile(const panda_file::File *pf, const CString &desc)
{
ASSERT(GetJSPandaFile(pf) == nullptr);
@@ -32,9 +32,9 @@ class EcmaVm;
namespace ecmascript {
class Program;
class JSPandaFileManager {
class PUBLIC_API JSPandaFileManager {
public:
PUBLIC_API ~JSPandaFileManager();
~JSPandaFileManager();
static JSPandaFileManager *GetInstance()
{
@@ -44,16 +44,16 @@ public:
JSHandle<Program> GenerateProgram(EcmaVM *vm, const JSPandaFile *jsPandaFile);
const JSPandaFile* PUBLIC_API LoadAotInfoFromPf(const std::string &filename,
const JSPandaFile* LoadAotInfoFromPf(const CString &filename,
std::vector<MethodPcInfo> *methodPcInfos);
const JSPandaFile *LoadJSPandaFile(const std::string &filename);
const JSPandaFile *LoadJSPandaFile(const CString &filename);
const JSPandaFile *LoadJSPandaFile(const std::string &filename, const void *buffer, size_t size);
const JSPandaFile *LoadJSPandaFile(const CString &filename, const void *buffer, size_t size);
JSPandaFile *OpenJSPandaFile(const std::string &filename);
JSPandaFile *OpenJSPandaFile(const CString &filename);
JSPandaFile *NewJSPandaFile(const panda_file::File *pf, const std::string &desc);
JSPandaFile *NewJSPandaFile(const panda_file::File *pf, const CString &desc);
tooling::ecmascript::JSPtExtractor *GetJSPtExtractor(const JSPandaFile *jsPandaFile);
@@ -81,10 +81,10 @@ private:
static void FreeBuffer(void *mem);
};
const JSPandaFile *GenerateJSPandaFile(const panda_file::File *pf, const std::string &desc);
const JSPandaFile *GenerateJSPandaFile(const panda_file::File *pf, const CString &desc);
void ReleaseJSPandaFile(const JSPandaFile *jsPandaFile);
const JSPandaFile *GetJSPandaFile(const panda_file::File *pf);
const JSPandaFile *FindJSPandaFile(const std::string &filename);
const JSPandaFile *FindJSPandaFile(const CString &filename);
void InsertJSPandaFile(const JSPandaFile *jsPandaFile);
void IncreaseRefJSPandaFile(const JSPandaFile *jsPandaFile);
void DecreaseRefJSPandaFile(const JSPandaFile *jsPandaFile);
@@ -27,7 +27,7 @@ using ModuleTag = jspandafile::ModuleTag;
using StringData = panda_file::StringData;
JSHandle<JSTaggedValue> ModuleDataExtractor::ParseModule(JSThread *thread, const JSPandaFile *jsPandaFile,
const std::string &descriptor)
const CString &descriptor)
{
const panda_file::File *pf = jsPandaFile->GetPandaFile();
Span<const uint32_t> classIndexes = pf->GetClasses();
@@ -59,7 +59,7 @@ JSHandle<JSTaggedValue> ModuleDataExtractor::ParseModule(JSThread *thread, const
JSHandle<SourceTextModule> moduleRecord = factory->NewSourceTextModule();
ModuleDataExtractor::ExtractModuleDatas(thread, jsPandaFile, moduleId, moduleRecord);
JSHandle<EcmaString> ecmaModuleFilename = factory->NewFromStdString(descriptor);
JSHandle<EcmaString> ecmaModuleFilename = factory->NewFromString(descriptor);
moduleRecord->SetEcmaModuleFilename(thread, ecmaModuleFilename);
moduleRecord->SetStatus(ModuleStatus::UNINSTANTIATED);
@@ -35,7 +35,7 @@ public:
panda_file::File::EntityId moduleId,
JSHandle<SourceTextModule> &moduleRecord);
static JSHandle<JSTaggedValue> ParseModule(JSThread *thread, const JSPandaFile *jsPandaFile,
const std::string &descriptor);
const CString &descriptor);
};
} // namespace panda::ecmascript
#endif // ECMASCRIPT_JSPANDAFILE_MODULE_DATA_EXTRACTOR_H
@@ -132,7 +132,7 @@ JSTaggedValue PandaFileTranslator::ParseConstPool(EcmaVM *vm, const JSPandaFile
JSHandle<JSHClass> asyncDynclass = JSHandle<JSHClass>::Cast(env->GetAsyncFunctionClass());
JSHandle<JSHClass> generatorDynclass = JSHandle<JSHClass>::Cast(env->GetGeneratorFunctionClass());
const std::unordered_map<uint32_t, uint64_t> &constpoolMap = jsPandaFile->GetConstpoolMap();
const CUnorderedMap<uint32_t, uint64_t> &constpoolMap = jsPandaFile->GetConstpoolMap();
[[maybe_unused]] uint32_t mainMethodIndex = jsPandaFile->GetMainMethodIndex();
for (const auto &it : constpoolMap) {
ConstPoolValue value(it.second);
@@ -35,7 +35,7 @@ JSTaggedValue ScopeInfoExtractor::GenerateScopeInfo(JSThread *thread, uint16_t s
for (size_t i = 1; i < length; i += 2) { // 2: Each literal buffer contains a pair of key-value.
JSTaggedValue val = elementsLiteral->Get(i);
ASSERT(val.IsString());
std::string name = base::StringHelper::ToStdString(EcmaString::Cast(val.GetTaggedObject()));
CString name = ConvertToString(EcmaString::Cast(val.GetTaggedObject()));
uint32_t slot = elementsLiteral->Get(i + 1).GetInt();
scopeDebugInfo->scopeInfo.insert(std::make_pair(name, slot));
}
@@ -20,7 +20,7 @@
namespace panda::ecmascript {
struct ScopeDebugInfo {
std::unordered_map<std::string, uint32_t> scopeInfo;
CUnorderedMap<CString, uint32_t> scopeInfo;
};
class ScopeInfoExtractor {
+7 -1
View File
@@ -24,7 +24,13 @@
#include "libpandabase/macros.h"
namespace panda::ecmascript {
constexpr int BASE = 10;
long CStringToL(const CString &str)
{
[[maybe_unused]] char *endPtr = nullptr;
int64_t result = std::strtol(str.c_str(), &endPtr, BASE);
ASSERT(!(result == 0 && str.c_str() == endPtr) && "CString argument is not long int");
return result;
}
int64_t CStringToLL(const CString &str)
{
+26
View File
@@ -30,9 +30,22 @@ class JSTaggedValue;
using CString = std::basic_string<char, std::char_traits<char>, CAddressAllocator<char>>;
using CStringStream = std::basic_stringstream<char, std::char_traits<char>, CAddressAllocator<char>>;
struct CStringHash {
using argument_type = panda::ecmascript::CString;
using result_type = std::size_t;
size_t operator()(const CString &str) const noexcept
{
return std::hash<std::string_view>()(std::string_view(str.data(), str.size()));
}
};
constexpr int BASE = 10;
// PRINT will skip '\0' in utf16 during conversion of utf8
enum StringConvertedUsage { PRINT, LOGICOPERATION };
long CStringToL(const CString &str);
int64_t CStringToLL(const CString &str);
uint64_t CStringToULL(const CString &str);
float CStringToF(const CString &str);
@@ -80,4 +93,17 @@ std::enable_if_t<std::is_integral_v<T>, CString> ToCString(T number)
}
} // namespace panda::ecmascript
namespace std {
template <>
struct hash<panda::ecmascript::CString> {
using argument_type = panda::ecmascript::CStringHash::argument_type;
using result_type = panda::ecmascript::CStringHash::result_type;
size_t operator()(const panda::ecmascript::CString &str) const noexcept
{
return panda::ecmascript::CStringHash()(str);
}
};
} // namespace std
#endif // ECMASCRIPT_MEM_C_STRING_H
+6 -6
View File
@@ -80,11 +80,11 @@ void ModuleManager::StoreModuleValue(JSTaggedValue key, JSTaggedValue value)
currentModule->StoreModuleValue(thread, keyHandle, valueHandle);
}
JSHandle<SourceTextModule> ModuleManager::HostGetImportedModule(const std::string &referencingModule)
JSHandle<SourceTextModule> ModuleManager::HostGetImportedModule(const CString &referencingModule)
{
ObjectFactory *factory = vm_->GetFactory();
JSHandle<JSTaggedValue> referencingHandle =
JSHandle<JSTaggedValue>::Cast(factory->NewFromStdString(referencingModule));
JSHandle<JSTaggedValue>::Cast(factory->NewFromString(referencingModule));
int entry =
NameDictionary::Cast(resolvedModules_.GetTaggedObject())->FindEntry(referencingHandle.GetTaggedValue());
LOG_IF(entry == -1, FATAL, ECMASCRIPT) << "cannot get module: " << referencingModule;
@@ -93,12 +93,12 @@ JSHandle<SourceTextModule> ModuleManager::HostGetImportedModule(const std::strin
NameDictionary::Cast(resolvedModules_.GetTaggedObject())->GetValue(entry));
}
JSHandle<SourceTextModule> ModuleManager::HostResolveImportedModule(const std::string &referencingModule)
JSHandle<SourceTextModule> ModuleManager::HostResolveImportedModule(const CString &referencingModule)
{
JSThread *thread = vm_->GetJSThread();
ObjectFactory *factory = vm_->GetFactory();
JSHandle<JSTaggedValue> referencingHandle =
JSHandle<JSTaggedValue>::Cast(factory->NewFromStdString(referencingModule));
JSHandle<JSTaggedValue>::Cast(factory->NewFromString(referencingModule));
int entry =
NameDictionary::Cast(resolvedModules_.GetTaggedObject())->FindEntry(referencingHandle.GetTaggedValue());
if (entry != -1) {
@@ -119,13 +119,13 @@ JSHandle<SourceTextModule> ModuleManager::HostResolveImportedModule(const std::s
return JSHandle<SourceTextModule>::Cast(moduleRecord);
}
void ModuleManager::AddResolveImportedModule(const JSPandaFile *jsPandaFile, const std::string &referencingModule)
void ModuleManager::AddResolveImportedModule(const JSPandaFile *jsPandaFile, const CString &referencingModule)
{
JSThread *thread = vm_->GetJSThread();
ObjectFactory *factory = vm_->GetFactory();
JSHandle<JSTaggedValue> moduleRecord = ModuleDataExtractor::ParseModule(thread, jsPandaFile, referencingModule);
JSHandle<JSTaggedValue> referencingHandle =
JSHandle<JSTaggedValue>::Cast(factory->NewFromStdString(referencingModule));
JSHandle<JSTaggedValue>::Cast(factory->NewFromString(referencingModule));
JSHandle<NameDictionary> dict(thread, resolvedModules_);
resolvedModules_ =
NameDictionary::Put(thread, dict, referencingHandle, moduleRecord, PropertyAttributes::Default())
+3 -3
View File
@@ -28,10 +28,10 @@ public:
JSTaggedValue GetModuleValueInner(JSTaggedValue key);
JSTaggedValue GetModuleValueOutter(JSTaggedValue key);
void StoreModuleValue(JSTaggedValue key, JSTaggedValue value);
JSHandle<SourceTextModule> HostGetImportedModule(const std::string &referencingModule);
JSHandle<SourceTextModule> HostResolveImportedModule(const std::string &referencingModule);
JSHandle<SourceTextModule> HostGetImportedModule(const CString &referencingModule);
JSHandle<SourceTextModule> HostResolveImportedModule(const CString &referencingModule);
JSTaggedValue GetModuleNamespace(JSTaggedValue localName);
void AddResolveImportedModule(const JSPandaFile *jsPandaFile, const std::string &referencingModule);
void AddResolveImportedModule(const JSPandaFile *jsPandaFile, const CString &referencingModule);
void Iterate(const RootVisitor &v);
private:
+5 -5
View File
@@ -112,15 +112,15 @@ JSHandle<SourceTextModule> SourceTextModule::HostResolveImportedModule(JSThread
const JSHandle<SourceTextModule> &module,
const JSHandle<JSTaggedValue> &moduleRequest)
{
std::string moduleFilename = base::StringHelper::ToStdString(EcmaString::Cast(moduleRequest->GetHeapObject()));
CString moduleFilename = ConvertToString(EcmaString::Cast(moduleRequest->GetHeapObject()));
ASSERT(module->GetEcmaModuleFilename().IsHeapObject());
std::string baseFilename =
base::StringHelper::ToStdString(EcmaString::Cast(module->GetEcmaModuleFilename().GetHeapObject()));
CString baseFilename =
ConvertToString(EcmaString::Cast(module->GetEcmaModuleFilename().GetHeapObject()));
int suffixEnd = moduleFilename.find_last_of('.');
if (suffixEnd == -1) {
RETURN_HANDLE_IF_ABRUPT_COMPLETION(SourceTextModule, thread);
}
std::string moduleFullname;
CString moduleFullname;
if (moduleFilename[0] == '/') { // absoluteFilePath
moduleFullname = moduleFilename.substr(0, suffixEnd) + ".abc";
} else {
@@ -657,7 +657,7 @@ void SourceTextModule::ModuleExecution(JSThread *thread, const JSHandle<SourceTe
{
JSTaggedValue moduleFileName = module->GetEcmaModuleFilename();
ASSERT(moduleFileName.IsString());
std::string moduleFilenameStr = base::StringHelper::ToStdString(EcmaString::Cast(moduleFileName.GetHeapObject()));
CString moduleFilenameStr = ConvertToString(EcmaString::Cast(moduleFileName.GetHeapObject()));
const JSPandaFile *jsPandaFile = JSPandaFileManager::GetInstance()->LoadJSPandaFile(moduleFilenameStr);
if (jsPandaFile == nullptr) {
LOG_ECMA(ERROR) << "open jsPandaFile " << moduleFilenameStr << " error";
+4 -4
View File
@@ -290,7 +290,7 @@ bool JSNApi::Execute(EcmaVM *vm, const std::string &fileName, const std::string
std::vector<std::string> argv;
LOG_ECMA(DEBUG) << "start to execute ark file" << fileName;
JSThread *thread = vm->GetAssociatedJSThread();
if (!ecmascript::JSPandaFileExecutor::ExecuteFromFile(thread, fileName, entry, argv)) {
if (!ecmascript::JSPandaFileExecutor::ExecuteFromFile(thread, fileName.c_str(), entry, argv)) {
LOG_ECMA(ERROR) << "Cannot execute ark file '" << fileName
<< "' with entry '" << entry << "'" << std::endl;
return false;
@@ -303,7 +303,7 @@ bool JSNApi::Execute(EcmaVM *vm, const uint8_t *data, int32_t size,
{
std::vector<std::string> argv;
JSThread *thread = vm->GetAssociatedJSThread();
if (!ecmascript::JSPandaFileExecutor::ExecuteFromBuffer(thread, data, size, entry, argv, filename)) {
if (!ecmascript::JSPandaFileExecutor::ExecuteFromBuffer(thread, data, size, entry, argv, filename.c_str())) {
LOG_ECMA(ERROR) << "Cannot execute ark buffer file '" << filename
<< "' with entry '" << entry << "'" << std::endl;
return false;
@@ -483,7 +483,7 @@ bool JSNApi::ExecuteModuleFromBuffer(EcmaVM *vm, const void *data, int32_t size,
{
std::vector<std::string> argv;
JSThread *thread = vm->GetAssociatedJSThread();
if (!ecmascript::JSPandaFileExecutor::ExecuteFromBuffer(thread, data, size, ENTRY_POINTER, argv, file)) {
if (!ecmascript::JSPandaFileExecutor::ExecuteFromBuffer(thread, data, size, ENTRY_POINTER, argv, file.c_str())) {
std::cerr << "Cannot execute panda file from memory" << std::endl;
return false;
}
@@ -494,7 +494,7 @@ Local<ObjectRef> JSNApi::GetExportObject(EcmaVM *vm, const std::string &file, co
{
ecmascript::ModuleManager *moduleManager = vm->GetModuleManager();
JSThread *thread = vm->GetJSThread();
JSHandle<ecmascript::SourceTextModule> ecmaModule = moduleManager->HostResolveImportedModule(file);
JSHandle<ecmascript::SourceTextModule> ecmaModule = moduleManager->HostResolveImportedModule(file.c_str());
ObjectFactory *factory = vm->GetFactory();
JSHandle<EcmaString> keyHandle = factory->NewFromStdStringUnCheck(key, true);
+6 -6
View File
@@ -36,10 +36,10 @@
namespace panda::ecmascript {
constexpr uint32_t PANDA_FILE_ALIGNMENT = 4096;
void SnapShot::MakeSnapShotProgramObject(Program *program, const panda_file::File *pf, const std::string &fileName)
void SnapShot::MakeSnapShotProgramObject(Program *program, const panda_file::File *pf, const CString &fileName)
{
std::fstream write;
std::pair<bool, std::string> filePath = VerifyFilePath(fileName);
std::pair<bool, CString> filePath = VerifyFilePath(fileName);
if (!filePath.first) {
LOG(ERROR, RUNTIME) << "snapshot file path error";
return;
@@ -117,13 +117,13 @@ void SnapShot::MakeSnapShotProgramObject(Program *program, const panda_file::Fil
write.close();
}
const JSPandaFile *SnapShot::DeserializeGlobalEnvAndProgram(const std::string &abcFile, const std::string &snapshotFile)
const JSPandaFile *SnapShot::DeserializeGlobalEnvAndProgram(const CString &abcFile, const CString &snapshotFile)
{
SnapShotSerialize serialize(vm_, false);
serialize.GeneratedNativeMethod();
std::pair<bool, std::string> filePath = VerifyFilePath(snapshotFile);
std::pair<bool, CString> filePath = VerifyFilePath(snapshotFile);
if (!filePath.first) {
LOG(ERROR, RUNTIME) << "snapshot file path error";
return nullptr;
@@ -202,7 +202,7 @@ size_t SnapShot::AlignUpPageSize(size_t spaceSize)
return PAGE_SIZE_ALIGN_UP * (spaceSize / PAGE_SIZE_ALIGN_UP + 1);
}
std::pair<bool, std::string> SnapShot::VerifyFilePath(const std::string &filePath)
std::pair<bool, CString> SnapShot::VerifyFilePath(const CString &filePath)
{
if (filePath.size() > PATH_MAX) {
return std::make_pair(false, "");
@@ -210,7 +210,7 @@ std::pair<bool, std::string> SnapShot::VerifyFilePath(const std::string &filePat
CVector<char> resolvedPath(PATH_MAX);
auto result = realpath(filePath.c_str(), resolvedPath.data());
if (result == resolvedPath.data() || errno == ENOENT) {
return std::make_pair(true, std::string(resolvedPath.data()));
return std::make_pair(true, CString(resolvedPath.data()));
}
return std::make_pair(false, "");
}
+4 -4
View File
@@ -33,9 +33,9 @@ public:
~SnapShot() = default;
void MakeSnapShotProgramObject(Program *program, const panda_file::File *pf,
const std::string &fileName = "./snapshot");
const JSPandaFile *DeserializeGlobalEnvAndProgram(const std::string &abcFile,
const std::string &snapshotFile = "./snapshot");
const CString &fileName = "./snapshot");
const JSPandaFile *DeserializeGlobalEnvAndProgram(const CString &abcFile,
const CString &snapshotFile = "./snapshot");
private:
struct Header {
@@ -45,7 +45,7 @@ private:
private:
size_t AlignUpPageSize(size_t spaceSize);
std::pair<bool, std::string> VerifyFilePath(const std::string &filePath);
std::pair<bool, CString> VerifyFilePath(const CString &filePath);
NO_MOVE_SEMANTIC(SnapShot);
NO_COPY_SEMANTIC(SnapShot);
+4 -9
View File
@@ -225,14 +225,14 @@ void DebuggerImpl::DispatcherImpl::SetBlackboxPatterns(const DispatchRequest &re
DispatchResponse DebuggerImpl::Enable([[maybe_unused]] std::unique_ptr<EnableParams> params, UniqueDebuggerId *id)
{
ASSERT(id != nullptr);
*id = "0";
*id = 0;
return DispatchResponse::Ok();
}
DispatchResponse DebuggerImpl::EvaluateOnCallFrame(std::unique_ptr<EvaluateOnCallFrameParams> params,
std::unique_ptr<RemoteObject> *result)
{
CString callFrameId = params->GetCallFrameId();
CallFrameId callFrameId = params->GetCallFrameId();
CString expression = params->GetExpression();
return DispatchResponse::Create(backend_->EvaluateValue(callFrameId, expression, result));
}
@@ -248,13 +248,8 @@ DispatchResponse DebuggerImpl::GetPossibleBreakpoints(std::unique_ptr<GetPossibl
DispatchResponse DebuggerImpl::GetScriptSource(std::unique_ptr<GetScriptSourceParams> params, CString *source)
{
auto scriptFunc = [source](PtScript *script) -> bool {
*source = script->GetScriptSource();
return true;
};
if (!backend_->MatchScripts(scriptFunc, params->GetScriptId(), ScriptMatchType::SCRIPT_ID)) {
*source = "";
return DispatchResponse::Fail("unknown script id: " + params->GetScriptId());
if (!backend_->GetScriptSource(params->GetScriptId(), source)) {
return DispatchResponse::Fail("unknown script id: " + ToCString<uint32_t>(params->GetScriptId()));
}
return DispatchResponse::Ok();
+1 -3
View File
@@ -22,8 +22,6 @@
#include "ecmascript/tooling/dispatcher.h"
namespace panda::tooling::ecmascript {
using panda::ecmascript::CString;
class DebuggerImpl final {
public:
explicit DebuggerImpl(std::unique_ptr<JSBackend> backend) : backend_(std::move(backend)) {}
@@ -72,7 +70,7 @@ public:
NO_MOVE_SEMANTIC(DispatcherImpl);
using AgentHandler = void (DebuggerImpl::DispatcherImpl::*)(const DispatchRequest &request);
CMap<CString, AgentHandler> dispatcherTable_ {};
CUnorderedMap<CString, AgentHandler> dispatcherTable_ {};
std::unique_ptr<DebuggerImpl> debugger_ {};
};
+66 -47
View File
@@ -13,8 +13,9 @@
* limitations under the License.
*/
#include "js_backend.h"
#include <regex>
#include "ecmascript/tooling/agent/js_backend.h"
#include "ecmascript/jspandafile/js_pandafile.h"
#include "ecmascript/tooling/base/pt_events.h"
#include "ecmascript/tooling/front_end.h"
#include "ecmascript/tooling/protocol_handler.h"
@@ -25,7 +26,7 @@ using ObjectType = RemoteObject::TypeName;
using ObjectSubType = RemoteObject::SubTypeName;
using ObjectClassName = RemoteObject::ClassName;
const std::string DATA_APP_PATH = "/data/";
const CString DATA_APP_PATH = "/data/";
JSBackend::JSBackend(FrontEnd *frontend) : frontend_(frontend)
{
@@ -66,7 +67,7 @@ void JSBackend::NotifyPaused(std::optional<PtLocation> location, PauseReason rea
extractor = GetExtractor(detail.url_);
return true;
};
auto callbackFunc = [&detail](size_t line, size_t column) -> bool {
auto callbackFunc = [&detail](int32_t line, int32_t column) -> bool {
detail.line_ = line;
detail.column_ = column;
return true;
@@ -109,7 +110,7 @@ void JSBackend::NotifyAllScriptParsed()
}
}
bool JSBackend::NotifyScriptParsed(int32_t scriptId, const CString &fileName)
bool JSBackend::NotifyScriptParsed(ScriptId scriptId, const CString &fileName)
{
auto scriptFunc = []([[maybe_unused]] PtScript *script) -> bool {
return true;
@@ -118,26 +119,34 @@ bool JSBackend::NotifyScriptParsed(int32_t scriptId, const CString &fileName)
LOG(WARNING, DEBUGGER) << "NotifyScriptParsed: already loaded: " << fileName;
return false;
}
const panda_file::File *pfs = DebuggerApi::FindPandaFile(fileName);
if (pfs == nullptr) {
const JSPandaFile *jsPandaFile = nullptr;
::panda::ecmascript::JSPandaFileManager::GetInstance()->EnumerateJSPandaFiles([&jsPandaFile, &fileName](
const panda::ecmascript::JSPandaFile *pf) {
if (pf->GetJSPandaFileDesc() == fileName) {
jsPandaFile = pf;
return false;
}
return true;
});
if (jsPandaFile == nullptr) {
LOG(WARNING, DEBUGGER) << "NotifyScriptParsed: unknown file: " << fileName;
return false;
}
CString url;
CString source;
JSPtExtractor *extractor = GenerateExtractor(pfs);
JSPtExtractor *extractor = GenerateExtractor(jsPandaFile);
if (extractor == nullptr) {
LOG(ERROR, DEBUGGER) << "NotifyScriptParsed: Unsupported file: " << fileName;
return false;
}
CString url;
CString source;
const uint32_t MIN_SOURCE_CODE_LENGTH = 5; // maybe return 'ANDA' when source code is empty
for (const auto &method : extractor->GetMethodIdList()) {
source = CString(extractor->GetSourceCode(method));
source = extractor->GetSourceCode(method);
// only main function has source code
if (source.size() >= MIN_SOURCE_CODE_LENGTH) {
url = CString(extractor->GetSourceFile(method));
url = extractor->GetSourceFile(method);
break;
}
}
@@ -164,8 +173,8 @@ bool JSBackend::StepComplete(const PtLocation &location)
extractor = GetExtractor(script->GetUrl());
return true;
};
auto callbackFunc = [](size_t line, [[maybe_unused]] size_t column) -> bool {
return line == static_cast<size_t>(SPECIAL_LINE_MARK);
auto callbackFunc = [](int32_t line, [[maybe_unused]] int32_t column) -> bool {
return line == SPECIAL_LINE_MARK;
};
if (MatchScripts(scriptFunc, location.GetPandaFile(), ScriptMatchType::FILE_NAME) && extractor != nullptr &&
extractor->MatchWithOffset(callbackFunc, location.GetMethodId(), location.GetBytecodeOffset())) {
@@ -186,17 +195,14 @@ bool JSBackend::StepComplete(const PtLocation &location)
std::optional<Error> JSBackend::GetPossibleBreakpoints(Location *start, [[maybe_unused]] Location *end,
CVector<std::unique_ptr<BreakLocation>> *locations)
{
JSPtExtractor *extractor = nullptr;
auto scriptFunc = [this, &extractor](PtScript *script) -> bool {
extractor = GetExtractor(script->GetUrl());
return true;
};
if (!MatchScripts(scriptFunc, start->GetScriptId(), ScriptMatchType::SCRIPT_ID) || extractor == nullptr) {
auto iter = scripts_.find(start->GetScriptId());
if (iter == scripts_.end()) {
return Error(Error::Type::INVALID_BREAKPOINT, "extractor not found");
}
JSPtExtractor *extractor = GetExtractor(iter->second->GetUrl());
size_t line = start->GetLine();
size_t column = start->GetColumn();
int32_t line = start->GetLine();
int32_t column = start->GetColumn();
auto callbackFunc = []([[maybe_unused]] File::EntityId id, [[maybe_unused]] uint32_t offset) -> bool {
return true;
};
@@ -209,8 +215,8 @@ std::optional<Error> JSBackend::GetPossibleBreakpoints(Location *start, [[maybe_
return {};
}
std::optional<Error> JSBackend::SetBreakpointByUrl(const CString &url, size_t lineNumber,
size_t columnNumber, CString *out_id, CVector<std::unique_ptr<Location>> *outLocations)
std::optional<Error> JSBackend::SetBreakpointByUrl(const CString &url, int32_t lineNumber,
int32_t columnNumber, CString *out_id, CVector<std::unique_ptr<Location>> *outLocations)
{
JSPtExtractor *extractor = GetExtractor(url);
if (extractor == nullptr) {
@@ -218,7 +224,7 @@ std::optional<Error> JSBackend::SetBreakpointByUrl(const CString &url, size_t li
return Error(Error::Type::METHOD_NOT_FOUND, "Extractor not found");
}
CString scriptId;
ScriptId scriptId;
CString fileName;
auto scriptFunc = [&scriptId, &fileName](PtScript *script) -> bool {
scriptId = script->GetScriptId();
@@ -283,7 +289,7 @@ std::optional<Error> JSBackend::RemoveBreakpoint(const BreakpointDetails &metaDa
return Error(Error::Type::INVALID_BREAKPOINT, "Breakpoint not found");
}
LOG(INFO, DEBUGGER) << "remove breakpoint line number:" << metaData.line_;
LOG(INFO, DEBUGGER) << "remove breakpoint32_t line number:" << metaData.line_;
return ret;
}
@@ -304,7 +310,7 @@ std::optional<Error> JSBackend::Resume()
std::optional<Error> JSBackend::StepInto()
{
JSMethod *method = DebuggerApi::GetMethod(ecmaVm_);
JSPtExtractor *extractor = GetExtractor(method->GetPandaFile());
JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile());
if (extractor == nullptr) {
LOG(ERROR, DEBUGGER) << "StepInto: extractor is null";
return Error(Error::Type::METHOD_NOT_FOUND, "Extractor not found");
@@ -319,7 +325,7 @@ std::optional<Error> JSBackend::StepInto()
std::optional<Error> JSBackend::StepOver()
{
JSMethod *method = DebuggerApi::GetMethod(ecmaVm_);
JSPtExtractor *extractor = GetExtractor(method->GetPandaFile());
JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile());
if (extractor == nullptr) {
LOG(ERROR, DEBUGGER) << "StepOver: extractor is null";
return Error(Error::Type::METHOD_NOT_FOUND, "Extractor not found");
@@ -334,7 +340,7 @@ std::optional<Error> JSBackend::StepOver()
std::optional<Error> JSBackend::StepOut()
{
JSMethod *method = DebuggerApi::GetMethod(ecmaVm_);
JSPtExtractor *extractor = GetExtractor(method->GetPandaFile());
JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile());
if (extractor == nullptr) {
LOG(ERROR, DEBUGGER) << "StepOut: extractor is null";
return Error(Error::Type::METHOD_NOT_FOUND, "Extractor not found");
@@ -346,7 +352,7 @@ std::optional<Error> JSBackend::StepOut()
return {};
}
std::optional<Error> JSBackend::EvaluateValue(const CString &callFrameId, const CString &expression,
std::optional<Error> JSBackend::EvaluateValue(CallFrameId callFrameId, const CString &expression,
std::unique_ptr<RemoteObject> *result)
{
JSMethod *method = DebuggerApi::GetMethod(ecmaVm_);
@@ -356,7 +362,7 @@ std::optional<Error> JSBackend::EvaluateValue(const CString &callFrameId, const
Exception::EvalError(ecmaVm_, StringRef::NewFromUtf8(ecmaVm_, "Runtime internal error")));
return Error(Error::Type::METHOD_NOT_FOUND, "Native Frame not support");
}
JSPtExtractor *extractor = GetExtractor(method->GetPandaFile());
JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile());
if (extractor == nullptr) {
LOG(ERROR, DEBUGGER) << "EvaluateValue: extractor is null";
*result = RemoteObject::FromTagged(ecmaVm_,
@@ -371,7 +377,7 @@ std::optional<Error> JSBackend::EvaluateValue(const CString &callFrameId, const
varValue = Trim(expression.substr(indexEqual + 1, expression.length()));
}
if (!varValue.empty() && callFrameId != "0") {
if (!varValue.empty() && callFrameId != 0) {
*result = RemoteObject::FromTagged(ecmaVm_,
Exception::EvalError(ecmaVm_, StringRef::NewFromUtf8(ecmaVm_, "Only allow set value in current frame")));
return Error(Error::Type::METHOD_NOT_FOUND, "Unsupported parent frame set value");
@@ -412,20 +418,21 @@ CString JSBackend::Trim(const CString &str)
return ret;
}
JSPtExtractor *JSBackend::GenerateExtractor(const panda_file::File *file)
JSPtExtractor *JSBackend::GenerateExtractor(const JSPandaFile *jsPandaFile)
{
if (file->GetFilename().substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH) {
const CString &fileName = jsPandaFile->GetJSPandaFileDesc();
if (fileName.substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH) {
return nullptr;
}
auto extractor = std::make_unique<JSPtExtractor>(file);
auto extractor = std::make_unique<JSPtExtractor>(jsPandaFile);
JSPtExtractor *res = extractor.get();
extractors_[file->GetFilename()] = std::move(extractor);
extractors_[fileName] = std::move(extractor);
return res;
}
JSPtExtractor *JSBackend::GetExtractor(const panda_file::File *file)
JSPtExtractor *JSBackend::GetExtractor(const JSPandaFile *jsPandaFile)
{
const std::string fileName = file->GetFilename();
const CString &fileName = jsPandaFile->GetJSPandaFileDesc();
if (extractors_.find(fileName) == extractors_.end()) {
return nullptr;
}
@@ -449,7 +456,7 @@ JSPtExtractor *JSBackend::GetExtractor(const CString &url)
bool JSBackend::GenerateCallFrames(CVector<std::unique_ptr<CallFrame>> *callFrames)
{
int32_t callFrameId = 0;
CallFrameId callFrameId = 0;
auto walkerFunc = [this, &callFrameId, &callFrames](const InterpretedFrameHandler *frameHandler) -> StackState {
JSMethod *method = DebuggerApi::GetMethod(frameHandler);
if (method->IsNative()) {
@@ -471,11 +478,10 @@ bool JSBackend::GenerateCallFrames(CVector<std::unique_ptr<CallFrame>> *callFram
}
bool JSBackend::GenerateCallFrame(CallFrame *callFrame,
const InterpretedFrameHandler *frameHandler, int32_t callFrameId)
const InterpretedFrameHandler *frameHandler, CallFrameId callFrameId)
{
JSMethod *method = DebuggerApi::GetMethod(frameHandler);
auto *pf = method->GetPandaFile();
JSPtExtractor *extractor = GetExtractor(pf);
JSPtExtractor *extractor = GetExtractor(method->GetJSPandaFile());
if (extractor == nullptr) {
LOG(ERROR, DEBUGGER) << "GenerateCallFrame: extractor is null";
return false;
@@ -492,7 +498,7 @@ bool JSBackend::GenerateCallFrame(CallFrame *callFrame,
LOG(ERROR, DEBUGGER) << "GenerateCallFrame: Unknown url: " << url;
return false;
}
auto callbackFunc = [&location](size_t line, size_t column) -> bool {
auto callbackFunc = [&location](int32_t line, int32_t column) -> bool {
location->SetLine(line);
location->SetColumn(column);
return true;
@@ -513,7 +519,7 @@ bool JSBackend::GenerateCallFrame(CallFrame *callFrame,
// functionName
CString functionName = DebuggerApi::ParseFunctionName(method);
callFrame->SetCallFrameId(DebuggerApi::ToCString(callFrameId))
callFrame->SetCallFrameId(callFrameId)
.SetFunctionName(functionName)
.SetLocation(std::move(location))
.SetUrl(url)
@@ -535,7 +541,7 @@ std::unique_ptr<Scope> JSBackend::GetLocalScopeChain(const InterpretedFrameHandl
.SetDescription(RemoteObject::ObjectDescription);
propertiesPair_[curObjectId_++] = Global<JSValueRef>(ecmaVm_, localObject);
JSPtExtractor *extractor = GetExtractor(DebuggerApi::GetMethod(frameHandler)->GetPandaFile());
JSPtExtractor *extractor = GetExtractor(DebuggerApi::GetMethod(frameHandler)->GetJSPandaFile());
if (extractor == nullptr) {
LOG(ERROR, DEBUGGER) << "GetScopeChain: extractor is null";
return localScope;
@@ -603,6 +609,18 @@ std::unique_ptr<Scope> JSBackend::GetGlobalScopeChain()
return globalScope;
}
bool JSBackend::GetScriptSource(ScriptId scriptId, CString *source)
{
auto iter = scripts_.find(scriptId);
if (iter == scripts_.end()) {
*source = "";
return false;
}
*source = iter->second->GetScriptSource();
return true;
}
void JSBackend::SetPauseOnException(bool flag)
{
pauseOnException_ = flag;
@@ -722,7 +740,7 @@ void JSBackend::GetProtoOrProtoType(const Local<JSValueRef> &value, bool isOwn,
outPropertyDesc->emplace_back(std::move(debuggerProperty));
}
void JSBackend::GetProperties(uint32_t objectId, bool isOwn, bool isAccessorOnly,
void JSBackend::GetProperties(RemoteObjectId objectId, bool isOwn, bool isAccessorOnly,
CVector<std::unique_ptr<PropertyDescriptor>> *outPropertyDesc)
{
auto iter = propertiesPair_.find(objectId);
@@ -773,7 +791,8 @@ void JSBackend::GetProperties(uint32_t objectId, bool isOwn, bool isAccessorOnly
GetProtoOrProtoType(value, isOwn, isAccessorOnly, outPropertyDesc);
}
void JSBackend::CallFunctionOn([[maybe_unused]] const CString &functionDeclaration, [[maybe_unused]] uint32_t objectId,
void JSBackend::CallFunctionOn([[maybe_unused]] const CString &functionDeclaration,
[[maybe_unused]] RemoteObjectId objectId,
[[maybe_unused]] const CVector<std::unique_ptr<CallArgument>> *arguments, [[maybe_unused]] bool isSilent,
[[maybe_unused]] bool returnByValue, [[maybe_unused]] bool generatePreview, [[maybe_unused]] bool userGesture,
[[maybe_unused]] bool awaitPromise, [[maybe_unused]] ExecutionContextId executionContextId,
+16 -19
View File
@@ -23,8 +23,6 @@
#include "libpandabase/macros.h"
namespace panda::tooling::ecmascript {
using panda::ecmascript::CString;
class JSBackend {
public:
explicit JSBackend(FrontEnd *frontend);
@@ -36,7 +34,7 @@ public:
void NotifyPaused(std::optional<PtLocation> location, PauseReason reason);
void NotifyResume();
void NotifyAllScriptParsed();
bool NotifyScriptParsed(int32_t scriptId, const CString &fileName);
bool NotifyScriptParsed(ScriptId scriptId, const CString &fileName);
bool StepComplete(const PtLocation &location);
std::optional<Error> GetPossibleBreakpoints(Location *start, Location *end,
@@ -46,7 +44,7 @@ public:
return debugger_;
}
std::optional<Error> SetBreakpointByUrl(const CString &url, size_t lineNumber, size_t columnNumber,
std::optional<Error> SetBreakpointByUrl(const CString &url, int32_t lineNumber, int32_t columnNumber,
CString *outId,
CVector<std::unique_ptr<Location>> *outLocations);
std::optional<Error> RemoveBreakpoint(const BreakpointDetails &metaData);
@@ -56,7 +54,7 @@ public:
std::optional<Error> StepInto();
std::optional<Error> StepOver();
std::optional<Error> StepOut();
std::optional<Error> EvaluateValue(const CString &callFrameId, const CString &expression,
std::optional<Error> EvaluateValue(CallFrameId callFrameId, const CString &expression,
std::unique_ptr<RemoteObject> *result);
/**
@@ -70,10 +68,6 @@ public:
for (const auto &script : scripts_) {
CString value;
switch (type) {
case ScriptMatchType::SCRIPT_ID: {
value = script.second->GetScriptId();
break;
}
case ScriptMatchType::URL: {
value = script.second->GetUrl();
break;
@@ -97,10 +91,12 @@ public:
return false;
}
bool GetScriptSource(ScriptId scriptId, CString *source);
void SetPauseOnException(bool flag);
void GetProperties(uint32_t objectId, bool isOwn, bool isAccessorOnly,
void GetProperties(RemoteObjectId objectId, bool isOwn, bool isAccessorOnly,
CVector<std::unique_ptr<PropertyDescriptor>> *outPropertyDesc);
void CallFunctionOn(const CString &functionDeclaration, uint32_t objectId,
void CallFunctionOn(const CString &functionDeclaration, RemoteObjectId objectId,
const CVector<std::unique_ptr<CallArgument>> *arguments, bool isSilent, bool returnByValue,
bool generatePreview, bool userGesture, bool awaitPromise, ExecutionContextId executionContextId,
const CString &objectGroup, bool throwOnSideEffect, std::unique_ptr<RemoteObject> *outRemoteObject);
@@ -115,16 +111,17 @@ private:
NO_MOVE_SEMANTIC(JSBackend);
NO_COPY_SEMANTIC(JSBackend);
CString Trim(const CString &str);
JSPtExtractor *GenerateExtractor(const panda_file::File *file);
JSPtExtractor *GetExtractor(const panda_file::File *file);
JSPtExtractor *GenerateExtractor(const JSPandaFile *jsPandaFile);
JSPtExtractor *GetExtractor(const JSPandaFile *jsPandaFile);
JSPtExtractor *GetExtractor(const CString &url);
bool GenerateCallFrame(CallFrame *callFrame, const InterpretedFrameHandler *frameHandler, int32_t frameId);
bool GenerateCallFrame(CallFrame *callFrame, const InterpretedFrameHandler *frameHandler, CallFrameId frameId);
std::unique_ptr<Scope> GetLocalScopeChain(const InterpretedFrameHandler *frameHandler,
std::unique_ptr<RemoteObject> *thisObj);
std::unique_ptr<Scope> GetGlobalScopeChain();
std::optional<Error> ConvertToLocal(Local<JSValueRef> &taggedValue, std::unique_ptr<RemoteObject> *result,
const CString &varValue);
std::optional<Error> SetVregValue(int32_t regIndex, std::unique_ptr<RemoteObject> *result, const CString &varValue);
std::optional<Error> SetVregValue(int32_t regIndex, std::unique_ptr<RemoteObject> *result,
const CString &varValue);
std::optional<Error> SetLexicalValue(int32_t level, std::unique_ptr<RemoteObject> *result,
const CString &varValue, uint32_t slot);
std::optional<Error> GetVregValue(int32_t regIndex, std::unique_ptr<RemoteObject> *result);
@@ -137,10 +134,10 @@ private:
const EcmaVM *ecmaVm_ {nullptr};
std::unique_ptr<JSPtHooks> hooks_ {nullptr};
JSDebugger *debugger_ {nullptr};
CMap<const std::string, std::unique_ptr<JSPtExtractor>> extractors_ {};
CMap<CString, std::unique_ptr<PtScript>> scripts_ {};
CMap<uint32_t, Global<JSValueRef>> propertiesPair_ {};
uint32_t curObjectId_ {0};
CUnorderedMap<CString, std::unique_ptr<JSPtExtractor>> extractors_ {};
CUnorderedMap<ScriptId, std::unique_ptr<PtScript>> scripts_ {};
CUnorderedMap<RemoteObjectId, Global<JSValueRef>> propertiesPair_ {};
RemoteObjectId curObjectId_ {0};
bool pauseOnException_ {false};
bool pauseOnNextByteCode_ {false};
std::unique_ptr<JSPtExtractor::SingleStepper> singleStepper_ {nullptr};
+2 -2
View File
@@ -74,8 +74,8 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName)
[[maybe_unused]] LocalScope scope(backend_->ecmaVm_);
static int32_t scriptId = 0;
if (backend_->NotifyScriptParsed(scriptId++, DebuggerApi::ConvertToString(pandaFileName.data()))) {
static uint32_t scriptId = 0;
if (backend_->NotifyScriptParsed(scriptId++, pandaFileName.data())) {
firstTime_ = true;
}
}
+2 -2
View File
@@ -116,7 +116,7 @@ DispatchResponse RuntimeImpl::GetProperties(std::unique_ptr<GetPropertiesParams>
[[maybe_unused]] std::optional<CVector<std::unique_ptr<PrivatePropertyDescriptor>>> *outPrivateProps,
[[maybe_unused]] std::optional<std::unique_ptr<ExceptionDetails>> *outExceptionDetails)
{
backend_->GetProperties(DebuggerApi::CStringToULL(params->GetObjectId()),
backend_->GetProperties(params->GetObjectId(),
params->GetOwnProperties(),
params->GetAccessPropertiesOnly(),
outPropertyDesc);
@@ -128,7 +128,7 @@ DispatchResponse RuntimeImpl::CallFunctionOn(std::unique_ptr<CallFunctionOnParam
[[maybe_unused]] std::optional<std::unique_ptr<ExceptionDetails>> *outExceptionDetails)
{
backend_->CallFunctionOn(params->GetFunctionDeclaration(),
DebuggerApi::CStringToULL(params->GetObjectId()),
params->GetObjectId(),
params->GetArguments(),
params->GetSilent(),
params->GetReturnByValue(),
+1 -3
View File
@@ -22,8 +22,6 @@
#include "ecmascript/tooling/dispatcher.h"
namespace panda::tooling::ecmascript {
using panda::ecmascript::CString;
class RuntimeImpl final {
public:
explicit RuntimeImpl(JSBackend *backend) : backend_(backend) {}
@@ -55,7 +53,7 @@ public:
private:
using AgentHandler = void (RuntimeImpl::DispatcherImpl::*)(const DispatchRequest &request);
CMap<CString, AgentHandler> dispatcherTable_ {};
CUnorderedMap<CString, AgentHandler> dispatcherTable_ {};
std::unique_ptr<RuntimeImpl> runtime_ {};
NO_COPY_SEMANTIC(DispatcherImpl);
+17 -17
View File
@@ -29,7 +29,7 @@ std::unique_ptr<BreakpointResolved> BreakpointResolved::Create(const EcmaVM *ecm
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "breakpointId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
breakpointResolved->breakpointId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
breakpointResolved->breakpointId_ = DebuggerApi::ToCString(result);
} else {
error += "'breakpointId' should a String;";
}
@@ -113,7 +113,7 @@ std::unique_ptr<Paused> Paused::Create(const EcmaVM *ecmaVm, const Local<JSValue
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "reason")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paused->reason_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paused->reason_ = DebuggerApi::ToCString(result);
} else {
error += "'reason' should a String;";
}
@@ -141,7 +141,7 @@ std::unique_ptr<Paused> Paused::Create(const EcmaVM *ecmaVm, const Local<JSValue
if (resultValue.IsEmpty()) {
error += "'hitBreakpoints' format invalid;";
}
breakPoints.emplace_back(DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()));
breakPoints.emplace_back(DebuggerApi::ToCString(result));
}
paused->hitBreakpoints_ = std::move(breakPoints);
} else {
@@ -224,7 +224,7 @@ std::unique_ptr<ScriptFailedToParse> ScriptFailedToParse::Create(const EcmaVM *e
Local<JSValueRef> result = Local<ObjectRef>(params)->Get(ecmaVm, StringRef::NewFromUtf8(ecmaVm, "scriptId"));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->scriptId_ = DebuggerApi::StringToInt(result);
} else {
error += "'scriptId' should a String;";
}
@@ -234,7 +234,7 @@ std::unique_ptr<ScriptFailedToParse> ScriptFailedToParse::Create(const EcmaVM *e
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "url")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->url_ = DebuggerApi::ToCString(result);
} else {
error += "'url' should a String;";
}
@@ -295,7 +295,7 @@ std::unique_ptr<ScriptFailedToParse> ScriptFailedToParse::Create(const EcmaVM *e
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "hash")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->hash_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->hash_ = DebuggerApi::ToCString(result);
} else {
error += "'hash' should a String;";
}
@@ -314,7 +314,7 @@ std::unique_ptr<ScriptFailedToParse> ScriptFailedToParse::Create(const EcmaVM *e
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "sourceMapURL")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->sourceMapUrl_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->sourceMapUrl_ = DebuggerApi::ToCString(result);
} else {
error += "'sourceMapURL' should a String;";
}
@@ -354,7 +354,7 @@ std::unique_ptr<ScriptFailedToParse> ScriptFailedToParse::Create(const EcmaVM *e
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptLanguage")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->scriptLanguage_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->scriptLanguage_ = DebuggerApi::ToCString(result);
} else {
error += "'scriptLanguage' should a String;";
}
@@ -362,7 +362,7 @@ std::unique_ptr<ScriptFailedToParse> ScriptFailedToParse::Create(const EcmaVM *e
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "embedderName")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->embedderName_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->embedderName_ = DebuggerApi::ToCString(result);
} else {
error += "'embedderName' should a String;";
}
@@ -381,7 +381,7 @@ Local<ObjectRef> ScriptFailedToParse::ToObject(const EcmaVM *ecmaVm)
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, scriptId_.c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(scriptId_).c_str())));
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "url")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, url_.c_str())));
@@ -477,7 +477,7 @@ std::unique_ptr<ScriptParsed> ScriptParsed::Create(const EcmaVM *ecmaVm, const L
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->scriptId_ = DebuggerApi::StringToInt(result);
} else {
error += "'scriptId' should a String;";
}
@@ -487,7 +487,7 @@ std::unique_ptr<ScriptParsed> ScriptParsed::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "url")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->url_ = DebuggerApi::ToCString(result);
} else {
error += "'url' should a String;";
}
@@ -548,7 +548,7 @@ std::unique_ptr<ScriptParsed> ScriptParsed::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "hash")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->hash_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->hash_ = DebuggerApi::ToCString(result);
} else {
error += "'hash' should a String;";
}
@@ -575,7 +575,7 @@ std::unique_ptr<ScriptParsed> ScriptParsed::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "sourceMapURL")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->sourceMapUrl_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->sourceMapUrl_ = DebuggerApi::ToCString(result);
} else {
error += "'sourceMapURL' should a String;";
}
@@ -615,7 +615,7 @@ std::unique_ptr<ScriptParsed> ScriptParsed::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptLanguage")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->scriptLanguage_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->scriptLanguage_ = DebuggerApi::ToCString(result);
} else {
error += "'scriptLanguage' should a String;";
}
@@ -623,7 +623,7 @@ std::unique_ptr<ScriptParsed> ScriptParsed::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "embedderName")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scriptEvent->embedderName_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scriptEvent->embedderName_ = DebuggerApi::ToCString(result);
} else {
error += "'embedderName' should a String;";
}
@@ -642,7 +642,7 @@ Local<ObjectRef> ScriptParsed::ToObject(const EcmaVM *ecmaVm)
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, scriptId_.c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(scriptId_).c_str())));
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "url")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, url_.c_str())));
+21 -22
View File
@@ -23,7 +23,6 @@
#include "ecmascript/tooling/base/pt_script.h"
#include "ecmascript/tooling/base/pt_types.h"
#include "ecmascript/tooling/dispatcher.h"
#include "ecmascript/mem/c_containers.h"
namespace panda::tooling::ecmascript {
using panda::ecmascript::EcmaVM;
@@ -99,13 +98,13 @@ public:
return &callFrames_;
}
Paused &SetCallFrames(CVector<std::unique_ptr<CallFrame>> call_frames)
Paused &SetCallFrames(CVector<std::unique_ptr<CallFrame>> callFrames)
{
callFrames_ = std::move(call_frames);
callFrames_ = std::move(callFrames);
return *this;
}
CString GetReason() const
const CString &GetReason() const
{
return reason_;
}
@@ -238,13 +237,13 @@ public:
return scriptId_;
}
ScriptFailedToParse &SetScriptId(const ScriptId &scriptId)
ScriptFailedToParse &SetScriptId(ScriptId scriptId)
{
scriptId_ = scriptId;
return *this;
}
CString GetUrl() const
const CString &GetUrl() const
{
return url_;
}
@@ -310,7 +309,7 @@ public:
return *this;
}
CString GetHash() const
const CString &GetHash() const
{
return hash_;
}
@@ -337,9 +336,9 @@ public:
return execContextAuxData_.has_value();
}
CString GetSourceMapURL() const
const CString &GetSourceMapURL() const
{
return sourceMapUrl_.value_or("");
return sourceMapUrl_.value();
}
ScriptFailedToParse &SetSourceMapURL(const CString &sourceMapUrl)
@@ -417,9 +416,9 @@ public:
return codeOffset_.has_value();
}
CString GetScriptLanguage() const
const CString &GetScriptLanguage() const
{
return scriptLanguage_.value_or("");
return scriptLanguage_.value();
}
ScriptFailedToParse &SetScriptLanguage(const CString &scriptLanguage)
@@ -433,9 +432,9 @@ public:
return scriptLanguage_.has_value();
}
CString GetEmbedderName() const
const CString &GetEmbedderName() const
{
return embedderName_.value_or("");
return embedderName_.value();
}
ScriptFailedToParse &SetEmbedderName(const CString &embedderName)
@@ -489,13 +488,13 @@ public:
return scriptId_;
}
ScriptParsed &SetScriptId(const ScriptId &scriptId)
ScriptParsed &SetScriptId(ScriptId scriptId)
{
scriptId_ = scriptId;
return *this;
}
CString GetUrl() const
const CString &GetUrl() const
{
return url_;
}
@@ -561,7 +560,7 @@ public:
return *this;
}
CString GetHash() const
const CString &GetHash() const
{
return hash_;
}
@@ -604,9 +603,9 @@ public:
return execContextAuxData_.has_value();
}
CString GetSourceMapURL() const
const CString &GetSourceMapURL() const
{
return sourceMapUrl_.value_or("");
return sourceMapUrl_.value();
}
ScriptParsed &SetSourceMapURL(const CString &sourceMapUrl)
@@ -684,9 +683,9 @@ public:
return codeOffset_.has_value();
}
CString GetScriptLanguage() const
const CString &GetScriptLanguage() const
{
return scriptLanguage_.value_or("");
return scriptLanguage_.value();
}
ScriptParsed &SetScriptLanguage(const CString &scriptLanguage)
@@ -700,9 +699,9 @@ public:
return scriptLanguage_.has_value();
}
CString GetEmbedderName() const
const CString &GetEmbedderName() const
{
return embedderName_.value_or("");
return embedderName_.value();
}
ScriptParsed &SetEmbedderName(const CString &embedderName)
+15 -15
View File
@@ -58,7 +58,7 @@ std::unique_ptr<EvaluateOnCallFrameParams> EvaluateOnCallFrameParams::Create(con
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "callFrameId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->callFrameId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->callFrameId_ = DebuggerApi::StringToInt(result);
} else {
error += "'callframeid' should be a String;";
}
@@ -69,7 +69,7 @@ std::unique_ptr<EvaluateOnCallFrameParams> EvaluateOnCallFrameParams::Create(con
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "expression")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->expression_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->expression_ = DebuggerApi::ToCString(result);
} else {
error += "'expression' should be a String;";
}
@@ -79,7 +79,7 @@ std::unique_ptr<EvaluateOnCallFrameParams> EvaluateOnCallFrameParams::Create(con
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "objectGroup")));
if (!result.IsEmpty() && result->IsString()) {
paramsObject->objectGroup_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->objectGroup_ = DebuggerApi::ToCString(result);
}
result = Local<ObjectRef>(params)->Get(ecmaVm,
@@ -189,7 +189,7 @@ std::unique_ptr<GetScriptSourceParams> GetScriptSourceParams::Create(const EcmaV
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->scriptId_ = DebuggerApi::StringToInt(result);
} else {
error += "'scriptId' should be a String;";
}
@@ -219,7 +219,7 @@ std::unique_ptr<RemoveBreakpointParams> RemoveBreakpointParams::Create(const Ecm
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "breakpointId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->breakpointId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->breakpointId_ = DebuggerApi::ToCString(result);
} else {
error += "'breakpointId' should be a String;";
}
@@ -314,7 +314,7 @@ std::unique_ptr<SetBlackboxPatternsParams> SetBlackboxPatternsParams::Create(con
Local<JSValueRef> value = Local<ObjectRef>(array)->Get(ecmaVm, key->ToString(ecmaVm));
if (value->IsString()) {
paramsObject->patterns_.emplace_back(
DebuggerApi::ConvertToString(StringRef::Cast(*value)->ToString()));
DebuggerApi::ToCString(value));
} else {
error += "'patterns' items should be a String;";
}
@@ -358,7 +358,7 @@ std::unique_ptr<SetBreakpointByUrlParams> SetBreakpointByUrlParams::Create(const
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "url")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->url_ = DebuggerApi::ToCString(result);
} else {
error += "'url' should be a String;";
}
@@ -366,7 +366,7 @@ std::unique_ptr<SetBreakpointByUrlParams> SetBreakpointByUrlParams::Create(const
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "urlRegex")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->urlRegex_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->urlRegex_ = DebuggerApi::ToCString(result);
} else {
error += "'urlRegex' should be a String;";
}
@@ -374,7 +374,7 @@ std::unique_ptr<SetBreakpointByUrlParams> SetBreakpointByUrlParams::Create(const
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptHash")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->scriptHash_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->scriptHash_ = DebuggerApi::ToCString(result);
} else {
error += "'scriptHash' should be a String;";
}
@@ -390,7 +390,7 @@ std::unique_ptr<SetBreakpointByUrlParams> SetBreakpointByUrlParams::Create(const
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "condition")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->condition_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->condition_ = DebuggerApi::ToCString(result);
} else {
error += "'condition' should be a String;";
}
@@ -418,7 +418,7 @@ std::unique_ptr<SetPauseOnExceptionsParams> SetPauseOnExceptionsParams::Create(c
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "state")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
if (!paramsObject->StoreState(DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString()))) {
if (!paramsObject->StoreState(DebuggerApi::ToCString(result))) {
error += "'state' is invalid;";
}
} else {
@@ -543,7 +543,7 @@ std::unique_ptr<GetPropertiesParams> GetPropertiesParams::Create(const EcmaVM *e
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "objectId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->objectId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->objectId_ = DebuggerApi::StringToInt(result);
} else {
error += "'objectId' should be a String;";
}
@@ -600,7 +600,7 @@ std::unique_ptr<CallFunctionOnParams> CallFunctionOnParams::Create(const EcmaVM
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "functionDeclaration")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->functionDeclaration_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->functionDeclaration_ = DebuggerApi::ToCString(result);
} else {
error += "'functionDeclaration' should be a String;";
}
@@ -611,7 +611,7 @@ std::unique_ptr<CallFunctionOnParams> CallFunctionOnParams::Create(const EcmaVM
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "objectId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->objectId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->objectId_ = DebuggerApi::StringToInt(result);
} else {
error += "'objectId' should be a String;";
}
@@ -701,7 +701,7 @@ std::unique_ptr<CallFunctionOnParams> CallFunctionOnParams::Create(const EcmaVM
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "objectGroup")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
paramsObject->objectGroup_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
paramsObject->objectGroup_ = DebuggerApi::ToCString(result);
} else {
error += "'objectGroup' should be a String;";
}
+16 -16
View File
@@ -70,12 +70,12 @@ public:
return Local<ObjectRef>();
}
CString GetCallFrameId()
CallFrameId GetCallFrameId()
{
return callFrameId_;
}
CString GetExpression()
const CString &GetExpression()
{
return expression_;
}
@@ -84,7 +84,7 @@ private:
NO_COPY_SEMANTIC(EvaluateOnCallFrameParams);
NO_MOVE_SEMANTIC(EvaluateOnCallFrameParams);
CString callFrameId_ {};
CallFrameId callFrameId_ {};
CString expression_ {};
std::optional<CString> objectGroup_ {};
std::optional<bool> includeCommandLineApi_ {};
@@ -277,9 +277,9 @@ public:
return line_;
}
CString GetUrl() const
const CString &GetUrl() const
{
return url_.value_or("");
return url_.value();
}
bool HasUrl() const
@@ -287,9 +287,9 @@ public:
return url_.has_value();
}
CString GetUrlRegex() const
const CString &GetUrlRegex() const
{
return urlRegex_.value_or("");
return urlRegex_.value();
}
bool HasUrlRegex() const
@@ -297,9 +297,9 @@ public:
return urlRegex_.has_value();
}
CString GetScriptHash() const
const CString &GetScriptHash() const
{
return scriptHash_.value_or("");
return scriptHash_.value();
}
bool HasScriptHash() const
@@ -317,9 +317,9 @@ public:
return column_.has_value();
}
CString GetCondition() const
const CString &GetCondition() const
{
return condition_.value_or("");
return condition_.value();
}
bool HasCondition() const
@@ -331,11 +331,11 @@ private:
NO_COPY_SEMANTIC(SetBreakpointByUrlParams);
NO_MOVE_SEMANTIC(SetBreakpointByUrlParams);
size_t line_ {0};
int32_t line_ {0};
std::optional<CString> url_ {};
std::optional<CString> urlRegex_ {};
std::optional<CString> scriptHash_ {};
std::optional<size_t> column_ {0};
std::optional<int32_t> column_ {0};
std::optional<CString> condition_ {};
};
@@ -520,7 +520,7 @@ public:
return Local<ObjectRef>();
}
CString GetFunctionDeclaration()
const CString &GetFunctionDeclaration()
{
return functionDeclaration_;
}
@@ -620,9 +620,9 @@ public:
return executionContextId_.has_value();
}
CString GetObjectGroup() const
const CString &GetObjectGroup() const
{
return objectGroup_.value_or("");
return objectGroup_.value();
}
bool HasObjectGroup() const
+1 -1
View File
@@ -22,7 +22,7 @@ Local<ObjectRef> EnableReturns::ToObject(const EcmaVM *ecmaVm)
result->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "debuggerId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, debuggerId_.c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(debuggerId_).c_str())));
return result;
}
+8 -9
View File
@@ -19,8 +19,6 @@
#include "ecmascript/tooling/base/pt_types.h"
namespace panda::tooling::ecmascript {
using panda::ecmascript::CString;
class PtBaseReturns : public PtBaseTypes {
public:
PtBaseReturns() = default;
@@ -38,7 +36,7 @@ private:
class EnableReturns : public PtBaseReturns {
public:
explicit EnableReturns(UniqueDebuggerId id) : debuggerId_(std::move(id)) {}
explicit EnableReturns(UniqueDebuggerId id) : debuggerId_(id) {}
~EnableReturns() override = default;
Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;
@@ -53,8 +51,8 @@ private:
class SetBreakpointByUrlReturns : public PtBaseReturns {
public:
explicit SetBreakpointByUrlReturns(CString id, CVector<std::unique_ptr<Location>> locations)
: id_(std::move(id)), locations_(std::move(locations))
explicit SetBreakpointByUrlReturns(const CString &id, CVector<std::unique_ptr<Location>> locations)
: id_(id), locations_(std::move(locations))
{}
~SetBreakpointByUrlReturns() override = default;
@@ -124,7 +122,8 @@ private:
class RestartFrameReturns : public PtBaseReturns {
public:
explicit RestartFrameReturns(CVector<std::unique_ptr<CallFrame>> callFrames) : callFrames_(std::move(callFrames))
explicit RestartFrameReturns(CVector<std::unique_ptr<CallFrame>> callFrames)
: callFrames_(std::move(callFrames))
{}
~RestartFrameReturns() override = default;
Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;
@@ -154,8 +153,8 @@ private:
class SetBreakpointReturns : public PtBaseReturns {
public:
explicit SetBreakpointReturns(CString id, std::unique_ptr<Location> location)
: breakpointId_(std::move(id)), location_(std::move(location))
explicit SetBreakpointReturns(const CString &id, std::unique_ptr<Location> location)
: breakpointId_(id), location_(std::move(location))
{}
~SetBreakpointReturns() override = default;
Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;
@@ -170,7 +169,7 @@ private:
class SetInstrumentationBreakpointReturns : public PtBaseReturns {
public:
explicit SetInstrumentationBreakpointReturns(CString id) : breakpointId_(std::move(id))
explicit SetInstrumentationBreakpointReturns(const CString &id) : breakpointId_(id)
{}
~SetInstrumentationBreakpointReturns() override = default;
Local<ObjectRef> ToObject(const EcmaVM *ecmaVm) override;
+5 -5
View File
@@ -17,11 +17,11 @@
#include "ecmascript/tooling/interface/debugger_api.h"
namespace panda::tooling::ecmascript {
PtScript::PtScript(int32_t scriptId, CString fileName, CString url, CString source)
: scriptId_(DebuggerApi::ToCString(scriptId)),
fileName_(std::move(fileName)),
url_(std::move(url)),
scriptSource_(std::move(source))
PtScript::PtScript(ScriptId scriptId, const CString &fileName, const CString &url, const CString &source)
: scriptId_(scriptId),
fileName_(fileName),
url_(url),
scriptSource_(source)
{
endLine_ = std::count(scriptSource_.begin(), scriptSource_.end(), '\n');
}
+10 -13
View File
@@ -17,13 +17,10 @@
#define ECMASCRIPT_TOOLING_BASE_PT_SCRIPT_H
#include "libpandabase/macros.h"
#include "ecmascript/mem/c_string.h"
#include "ecmascript/tooling/base/pt_types.h"
namespace panda::tooling::ecmascript {
using panda::ecmascript::CString;
enum class ScriptMatchType : uint8_t {
SCRIPT_ID,
URL,
FILE_NAME,
HASH,
@@ -31,20 +28,20 @@ enum class ScriptMatchType : uint8_t {
class PtScript {
public:
PtScript(int32_t scriptId, CString fileName, CString url, CString source);
PtScript(ScriptId scriptId, const CString &fileName, const CString &url, const CString &source);
~PtScript() = default;
CString GetScriptId() const
ScriptId GetScriptId() const
{
return scriptId_;
}
void SetScriptId(const CString &scriptId)
void SetScriptId(ScriptId scriptId)
{
scriptId_ = scriptId;
}
CString GetFileName() const
const CString &GetFileName() const
{
return fileName_;
}
@@ -54,7 +51,7 @@ public:
fileName_ = fileName;
}
CString GetUrl() const
const CString &GetUrl() const
{
return url_;
}
@@ -64,7 +61,7 @@ public:
url_ = url;
}
CString GetHash() const
const CString &GetHash() const
{
return hash_;
}
@@ -74,7 +71,7 @@ public:
hash_ = hash;
}
CString GetScriptSource() const
const CString &GetScriptSource() const
{
return scriptSource_;
}
@@ -84,7 +81,7 @@ public:
scriptSource_ = scriptSource;
}
CString GetSourceMapUrl() const
const CString &GetSourceMapUrl() const
{
return sourceMapUrl_;
}
@@ -108,7 +105,7 @@ private:
NO_COPY_SEMANTIC(PtScript);
NO_MOVE_SEMANTIC(PtScript);
CString scriptId_ {}; // start from 0, such as "0","1","2"...
ScriptId scriptId_ {}; // start from 0, such as "0","1","2"...
CString fileName_ {}; // binary file name, such as xx.bin
CString url_ {}; // source file name, such as xx.js
CString hash_ {}; // js source file hash code
+43 -43
View File
@@ -175,7 +175,7 @@ PrimitiveRemoteObject::PrimitiveRemoteObject(const EcmaVM *ecmaVm, const Local<J
this->SetType(ObjectType::Undefined);
} else if (tagged->IsNumber()) {
this->SetType(ObjectType::Number)
.SetDescription(DebuggerApi::ConvertToString(tagged->ToString(ecmaVm)->ToString()));
.SetDescription(DebuggerApi::ToCString(tagged->ToString(ecmaVm)));
double val = Local<NumberRef>(tagged)->Value();
if (!std::isfinite(val) || (val == 0 && ((bit_cast<uint64_t>(val) & DOUBLE_SIGN_MASK) == DOUBLE_SIGN_MASK))) {
this->SetUnserializableValue(this->GetDescription());
@@ -237,32 +237,32 @@ CString ObjectRemoteObject::DescriptionForObject(const EcmaVM *ecmaVm, const Loc
CString ObjectRemoteObject::DescriptionForArray(const EcmaVM *ecmaVm, const Local<ArrayRef> &tagged)
{
CString description = "Array(" + DebuggerApi::ToCString(tagged->Length(ecmaVm)) + ")";
CString description = "Array(" + ToCString<uint32_t>(tagged->Length(ecmaVm)) + ")";
return description;
}
CString ObjectRemoteObject::DescriptionForRegexp(const EcmaVM *ecmaVm, const Local<RegExpRef> &tagged)
{
CString regexpSource = DebuggerApi::ConvertToString(tagged->GetOriginalSource(ecmaVm)->ToString());
CString regexpSource = DebuggerApi::ToCString(tagged->GetOriginalSource(ecmaVm));
CString description = "/" + regexpSource + "/";
return description;
}
CString ObjectRemoteObject::DescriptionForDate(const EcmaVM *ecmaVm, const Local<DateRef> &tagged)
{
CString description = DebuggerApi::ConvertToString(tagged->ToString(ecmaVm)->ToString());
CString description = DebuggerApi::ToCString(tagged->ToString(ecmaVm));
return description;
}
CString ObjectRemoteObject::DescriptionForMap(const Local<MapRef> &tagged)
{
CString description = ("Map(" + DebuggerApi::ToCString(tagged->GetSize()) + ")");
CString description = ("Map(" + ToCString<uint32_t>(tagged->GetSize()) + ")");
return description;
}
CString ObjectRemoteObject::DescriptionForSet(const Local<SetRef> &tagged)
{
CString description = ("Set(" + DebuggerApi::ToCString(tagged->GetSize()) + ")");
CString description = ("Set(" + ToCString<uint32_t>(tagged->GetSize()) + ")");
return description;
}
@@ -270,20 +270,20 @@ CString ObjectRemoteObject::DescriptionForError(const EcmaVM *ecmaVm, const Loca
{
Local<JSValueRef> stack = StringRef::NewFromUtf8(ecmaVm, "stack");
Local<JSValueRef> result = Local<ObjectRef>(tagged)->Get(ecmaVm, stack);
return DebuggerApi::ConvertToString(result->ToString(ecmaVm)->ToString());
return DebuggerApi::ToCString(result->ToString(ecmaVm));
}
CString ObjectRemoteObject::DescriptionForArrayBuffer(const EcmaVM *ecmaVm, const Local<ArrayBufferRef> &tagged)
{
int32_t len = tagged->ByteLength(ecmaVm);
CString description = ("ArrayBuffer(" + DebuggerApi::ToCString(len) + ")");
CString description = ("ArrayBuffer(" + ToCString<uint32_t>(len) + ")");
return description;
}
CString SymbolRemoteObject::DescriptionForSymbol(const EcmaVM *ecmaVm, const Local<SymbolRef> &tagged) const
{
CString description =
"Symbol(" + DebuggerApi::ConvertToString(Local<StringRef>(tagged->GetDescription(ecmaVm))->ToString()) + ")";
"Symbol(" + DebuggerApi::ToCString(tagged->GetDescription(ecmaVm)) + ")";
return description;
}
@@ -296,7 +296,7 @@ CString FunctionRemoteObject::DescriptionForFunction(const EcmaVM *ecmaVm, const
sourceCode = "[js code]";
}
Local<StringRef> name = tagged->GetName(ecmaVm);
CString description = "function " + DebuggerApi::ConvertToString(name->ToString()) + "() { " + sourceCode + " }";
CString description = "function " + DebuggerApi::ToCString(name) + "( { " + sourceCode + " }";
return description;
}
@@ -313,7 +313,7 @@ std::unique_ptr<RemoteObject> RemoteObject::Create(const EcmaVM *ecmaVm, const L
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "type")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
auto type = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
auto type = DebuggerApi::ToCString(result);
if (ObjectType::Valid(type)) {
remoteObject->type_ = type;
} else {
@@ -328,7 +328,7 @@ std::unique_ptr<RemoteObject> RemoteObject::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "subtype")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
auto type = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
auto type = DebuggerApi::ToCString(result);
if (ObjectSubType::Valid(type)) {
remoteObject->subtype_ = type;
} else {
@@ -341,7 +341,7 @@ std::unique_ptr<RemoteObject> RemoteObject::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "className")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
remoteObject->className_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
remoteObject->className_ = DebuggerApi::ToCString(result);
} else {
error += "'className' should be a String;";
}
@@ -354,7 +354,7 @@ std::unique_ptr<RemoteObject> RemoteObject::Create(const EcmaVM *ecmaVm, const L
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "unserializableValue")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
remoteObject->unserializableValue_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
remoteObject->unserializableValue_ = DebuggerApi::ToCString(result);
} else {
error += "'unserializableValue' should be a String;";
}
@@ -362,7 +362,7 @@ std::unique_ptr<RemoteObject> RemoteObject::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "description")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
remoteObject->description_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
remoteObject->description_ = DebuggerApi::ToCString(result);
} else {
error += "'description' should be a String;";
}
@@ -370,7 +370,7 @@ std::unique_ptr<RemoteObject> RemoteObject::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "objectId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
remoteObject->objectId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
remoteObject->objectId_ = DebuggerApi::StringToInt(result);
} else {
error += "'objectId' should be a String;";
}
@@ -416,7 +416,7 @@ Local<ObjectRef> RemoteObject::ToObject(const EcmaVM *ecmaVm)
if (objectId_) {
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "objectId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, objectId_->c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(objectId_.value()).c_str())));
}
return params;
@@ -445,7 +445,7 @@ std::unique_ptr<ExceptionDetails> ExceptionDetails::Create(const EcmaVM *ecmaVm,
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "text")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
exceptionDetails->text_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
exceptionDetails->text_ = DebuggerApi::ToCString(result);
} else {
error += "'text' should be a String;";
}
@@ -475,7 +475,7 @@ std::unique_ptr<ExceptionDetails> ExceptionDetails::Create(const EcmaVM *ecmaVm,
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
exceptionDetails->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
exceptionDetails->scriptId_ = DebuggerApi::StringToInt(result);
} else {
error += "'scriptId' should be a String;";
}
@@ -483,7 +483,7 @@ std::unique_ptr<ExceptionDetails> ExceptionDetails::Create(const EcmaVM *ecmaVm,
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "url")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
exceptionDetails->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
exceptionDetails->url_ = DebuggerApi::ToCString(result);
} else {
error += "'url' should be a String;";
}
@@ -536,7 +536,7 @@ Local<ObjectRef> ExceptionDetails::ToObject(const EcmaVM *ecmaVm)
if (scriptId_) {
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, scriptId_->c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(scriptId_.value()).c_str())));
}
if (url_) {
params->Set(ecmaVm,
@@ -572,7 +572,7 @@ std::unique_ptr<InternalPropertyDescriptor> InternalPropertyDescriptor::Create(c
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "name")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
internalPropertyDescriptor->name_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
internalPropertyDescriptor->name_ = DebuggerApi::ToCString(result);
} else {
error += "'name' should be a String;";
}
@@ -631,7 +631,7 @@ std::unique_ptr<PrivatePropertyDescriptor> PrivatePropertyDescriptor::Create(con
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "name")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
propertyDescriptor->name_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
propertyDescriptor->name_ = DebuggerApi::ToCString(result);
} else {
error += "'name' should be a String;";
}
@@ -723,10 +723,10 @@ std::unique_ptr<PropertyDescriptor> PropertyDescriptor::FromProperty(const EcmaV
if (name->IsSymbol()) {
Local<SymbolRef> symbol(name);
nameStr =
"Symbol(" + DebuggerApi::ConvertToString(Local<SymbolRef>(name)->GetDescription(ecmaVm)->ToString()) + ")";
"Symbol(" + DebuggerApi::ToCString(Local<SymbolRef>(name)->GetDescription(ecmaVm)) + ")";
debuggerProperty->symbol_ = RemoteObject::FromTagged(ecmaVm, name);
} else {
nameStr = DebuggerApi::ConvertToString(name->ToString(ecmaVm)->ToString());
nameStr = DebuggerApi::ToCString(name->ToString(ecmaVm));
}
debuggerProperty->name_ = nameStr;
@@ -762,7 +762,7 @@ std::unique_ptr<PropertyDescriptor> PropertyDescriptor::Create(const EcmaVM *ecm
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "name")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
propertyDescriptor->name_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
propertyDescriptor->name_ = DebuggerApi::ToCString(result);
} else {
error += "'name' should be a String;";
}
@@ -946,7 +946,7 @@ std::unique_ptr<CallArgument> CallArgument::Create(const EcmaVM *ecmaVm, const L
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "unserializableValue")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
callArgument->unserializableValue_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
callArgument->unserializableValue_ = DebuggerApi::ToCString(result);
} else {
error += "'unserializableValue' should be a String;";
}
@@ -954,7 +954,7 @@ std::unique_ptr<CallArgument> CallArgument::Create(const EcmaVM *ecmaVm, const L
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "objectId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
callArgument->objectId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
callArgument->objectId_ = DebuggerApi::StringToInt(result);
} else {
error += "'objectId' should be a String;";
}
@@ -982,7 +982,7 @@ Local<ObjectRef> CallArgument::ToObject(const EcmaVM *ecmaVm)
if (objectId_) {
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "objectId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, objectId_->c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(objectId_.value()).c_str())));
}
return params;
@@ -1001,7 +1001,7 @@ std::unique_ptr<Location> Location::Create(const EcmaVM *ecmaVm, const Local<JSV
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
location->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
location->scriptId_ = DebuggerApi::StringToInt(result);
} else {
error += "'scriptId' should be a String;";
}
@@ -1040,7 +1040,7 @@ Local<ObjectRef> Location::ToObject(const EcmaVM *ecmaVm)
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, scriptId_.c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(scriptId_).c_str())));
params->Set(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "lineNumber")),
IntegerRef::New(ecmaVm, line_));
if (column_) {
@@ -1126,7 +1126,7 @@ std::unique_ptr<SearchMatch> SearchMatch::Create(const EcmaVM *ecmaVm, const Loc
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "lineContent")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
locationSearch->lineContent_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
locationSearch->lineContent_ = DebuggerApi::ToCString(result);
} else {
error += "'lineContent' should be a String;";
}
@@ -1167,7 +1167,7 @@ std::unique_ptr<LocationRange> LocationRange::Create(const EcmaVM *ecmaVm, const
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
locationRange->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
locationRange->scriptId_ = DebuggerApi::StringToInt(result);
} else {
error += "'scriptId' should be a String;";
}
@@ -1218,7 +1218,7 @@ Local<ObjectRef> LocationRange::ToObject(const EcmaVM *ecmaVm)
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, scriptId_.c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(scriptId_).c_str())));
ASSERT(start_ != nullptr);
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "object")),
@@ -1243,7 +1243,7 @@ std::unique_ptr<BreakLocation> BreakLocation::Create(const EcmaVM *ecmaVm, const
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
breakLocation->scriptId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
breakLocation->scriptId_ = DebuggerApi::StringToInt(result);
} else {
error += "'scriptId' should be a String;";
}
@@ -1271,7 +1271,7 @@ std::unique_ptr<BreakLocation> BreakLocation::Create(const EcmaVM *ecmaVm, const
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "type")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
auto type = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
auto type = DebuggerApi::ToCString(result);
if (BreakType::Valid(type)) {
breakLocation->type_ = type;
} else {
@@ -1295,7 +1295,7 @@ Local<ObjectRef> BreakLocation::ToObject(const EcmaVM *ecmaVm)
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "scriptId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, scriptId_.c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(scriptId_).c_str())));
params->Set(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "lineNumber")),
IntegerRef::New(ecmaVm, line_));
if (column_) {
@@ -1325,7 +1325,7 @@ std::unique_ptr<Scope> Scope::Create(const EcmaVM *ecmaVm, const Local<JSValueRe
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "type")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
auto type = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
auto type = DebuggerApi::ToCString(result);
if (Scope::Type::Valid(type)) {
scope->type_ = type;
} else {
@@ -1355,7 +1355,7 @@ std::unique_ptr<Scope> Scope::Create(const EcmaVM *ecmaVm, const Local<JSValueRe
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "name")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
scope->name_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
scope->name_ = DebuggerApi::ToCString(result);
} else {
error += "'name' should be a String;";
}
@@ -1439,7 +1439,7 @@ std::unique_ptr<CallFrame> CallFrame::Create(const EcmaVM *ecmaVm, const Local<J
Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "callFrameId")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
callFrame->callFrameId_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
callFrame->callFrameId_ = DebuggerApi::StringToInt(result);
} else {
error += "'callFrameId' should be a String;";
}
@@ -1449,7 +1449,7 @@ std::unique_ptr<CallFrame> CallFrame::Create(const EcmaVM *ecmaVm, const Local<J
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "functionName")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
callFrame->functionName_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
callFrame->functionName_ = DebuggerApi::ToCString(result);
} else {
error += "'functionName' should be a String;";
}
@@ -1488,7 +1488,7 @@ std::unique_ptr<CallFrame> CallFrame::Create(const EcmaVM *ecmaVm, const Local<J
result = Local<ObjectRef>(params)->Get(ecmaVm, Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "url")));
if (!result.IsEmpty() && !result->IsUndefined()) {
if (result->IsString()) {
callFrame->url_ = DebuggerApi::ConvertToString(StringRef::Cast(*result)->ToString());
callFrame->url_ = DebuggerApi::ToCString(result);
} else {
error += "'url' should be a String;";
}
@@ -1558,7 +1558,7 @@ Local<ObjectRef> CallFrame::ToObject(const EcmaVM *ecmaVm)
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "callFrameId")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, callFrameId_.c_str())));
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, std::to_string(callFrameId_).c_str())));
params->Set(ecmaVm,
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, "functionName")),
Local<JSValueRef>(StringRef::NewFromUtf8(ecmaVm, functionName_.c_str())));
+57 -63
View File
@@ -26,10 +26,10 @@
namespace panda::tooling::ecmascript {
using panda::ecmascript::CList;
using panda::ecmascript::CMap;
using panda::ecmascript::CQueue;
using panda::ecmascript::CUnorderedMap;
using panda::ecmascript::CString;
using panda::ecmascript::CVector;
using panda::ecmascript::ToCString;
// ========== Base types begin
class PtBaseTypes {
@@ -55,7 +55,7 @@ using BreakpointId = CString;
struct BreakpointDetails {
static BreakpointId ToString(const BreakpointDetails &metaData)
{
return "id:" + DebuggerApi::ToCString(metaData.line_) + ":" + DebuggerApi::ToCString(metaData.column_) + ":" +
return "id:" + ToCString<uint32_t>(metaData.line_) + ":" + ToCString<uint32_t>(metaData.column_) + ":" +
metaData.url_;
}
@@ -76,27 +76,27 @@ struct BreakpointDetails {
CString lineStr = id.substr(lineStart + 1, columnStart - lineStart - 1);
CString columnStr = id.substr(columnStart + 1, urlStart - columnStart - 1);
CString url = id.substr(urlStart + 1);
metaData->line_ = DebuggerApi::CStringToULL(lineStr);
metaData->column_ = DebuggerApi::CStringToULL(columnStr);
metaData->line_ = DebuggerApi::CStringToInt(lineStr);
metaData->column_ = DebuggerApi::CStringToInt(columnStr);
metaData->url_ = url;
return true;
}
size_t line_ {0};
size_t column_ {0};
int32_t line_ {0};
int32_t column_ {0};
CString url_ {};
};
// Debugger.CallFrameId
using CallFrameId = CString;
using CallFrameId = uint32_t;
// ========== Runtime types begin
// Runtime.ScriptId
using ScriptId = CString;
using ScriptId = uint32_t;
// Runtime.RemoteObjectId
using RemoteObjectId = CString;
using RemoteObjectId = uint32_t;
// Runtime.ExecutionContextId
using ExecutionContextId = int32_t;
@@ -105,7 +105,7 @@ using ExecutionContextId = int32_t;
using UnserializableValue = CString;
// Runtime.UniqueDebuggerId
using UniqueDebuggerId = CString;
using UniqueDebuggerId = uint32_t;
// Runtime.RemoteObject
class RemoteObject : public PtBaseTypes {
@@ -120,7 +120,7 @@ public:
/*
* @see {#ObjectType}
*/
CString GetType() const
const CString &GetType() const
{
return type_;
}
@@ -133,9 +133,9 @@ public:
/*
* @see {#ObjectSubType}
*/
CString GetSubType() const
const CString &GetSubType() const
{
return subtype_.value_or("");
return subtype_.value();
}
RemoteObject &SetSubType(const CString &type)
@@ -149,9 +149,9 @@ public:
return subtype_.has_value();
}
CString GetClassName() const
const CString &GetClassName() const
{
return className_.value_or("");
return className_.value();
}
RemoteObject &SetClassName(const CString &className)
@@ -181,9 +181,9 @@ public:
return value_.has_value();
}
UnserializableValue GetUnserializableValue() const
const UnserializableValue &GetUnserializableValue() const
{
return unserializableValue_.value_or("");
return unserializableValue_.value();
}
RemoteObject &SetUnserializableValue(const UnserializableValue &unserializableValue)
@@ -197,9 +197,9 @@ public:
return unserializableValue_.has_value();
}
CString GetDescription() const
const CString &GetDescription() const
{
return description_.value_or("");
return description_.value();
}
RemoteObject &SetDescription(const CString &description)
@@ -215,21 +215,15 @@ public:
RemoteObjectId GetObjectId() const
{
return objectId_.value_or("");
return objectId_.value_or(0);
}
RemoteObject &SetObjectId(const RemoteObjectId &objectId)
RemoteObject &SetObjectId(RemoteObjectId objectId)
{
objectId_ = objectId;
return *this;
}
RemoteObject &SetObjectId(uint32_t objectId)
{
objectId_ = DebuggerApi::ToCString(objectId);
return *this;
}
bool HasObjectId() const
{
return objectId_.has_value();
@@ -426,7 +420,7 @@ public:
return *this;
}
CString GetText() const
const CString &GetText() const
{
return text_;
}
@@ -442,7 +436,7 @@ public:
return line_;
}
ExceptionDetails &SetLine(size_t line)
ExceptionDetails &SetLine(int32_t line)
{
line_ = line;
return *this;
@@ -453,7 +447,7 @@ public:
return column_;
}
ExceptionDetails &SetColumn(size_t column)
ExceptionDetails &SetColumn(int32_t column)
{
column_ = column;
return *this;
@@ -461,10 +455,10 @@ public:
ScriptId GetScriptId() const
{
return scriptId_.value_or("");
return scriptId_.value_or(0);
}
ExceptionDetails &SetScriptId(const ScriptId &scriptId)
ExceptionDetails &SetScriptId(ScriptId scriptId)
{
scriptId_ = scriptId;
return *this;
@@ -475,9 +469,9 @@ public:
return scriptId_.has_value();
}
CString GetUrl() const
const CString &GetUrl() const
{
return url_.value_or("");
return url_.value();
}
ExceptionDetails &SetUrl(const CString &url)
@@ -532,8 +526,8 @@ private:
int32_t exceptionId_ {0};
CString text_ {};
size_t line_ {0};
size_t column_ {0};
int32_t line_ {0};
int32_t column_ {0};
std::optional<ScriptId> scriptId_ {};
std::optional<CString> url_ {};
std::optional<std::unique_ptr<RemoteObject>> exception_ {};
@@ -883,9 +877,9 @@ public:
return value_.has_value();
}
UnserializableValue GetUnserializableValue() const
const UnserializableValue &GetUnserializableValue() const
{
return unserializableValue_.value_or("");
return unserializableValue_.value();
}
CallArgument &SetUnserializableValue(const UnserializableValue &unserializableValue)
@@ -901,10 +895,10 @@ public:
RemoteObjectId GetObjectId() const
{
return objectId_.value_or("");
return objectId_.value_or(0);
}
CallArgument &SetObjectId(const RemoteObjectId &objectId)
CallArgument &SetObjectId(RemoteObjectId objectId)
{
objectId_ = objectId;
return *this;
@@ -955,7 +949,7 @@ public:
return scriptId_;
}
Location &SetScriptId(const ScriptId &scriptId)
Location &SetScriptId(ScriptId scriptId)
{
scriptId_ = scriptId;
return *this;
@@ -966,7 +960,7 @@ public:
return line_;
}
Location &SetLine(size_t line)
Location &SetLine(int32_t line)
{
line_ = line;
return *this;
@@ -977,7 +971,7 @@ public:
return column_.value_or(-1);
}
Location &SetColumn(size_t column)
Location &SetColumn(int32_t column)
{
column_ = column;
return *this;
@@ -993,7 +987,7 @@ private:
NO_MOVE_SEMANTIC(Location);
ScriptId scriptId_ {};
size_t line_ {0};
int32_t line_ {0};
std::optional<int32_t> column_ {};
};
@@ -1011,7 +1005,7 @@ public:
return line_;
}
ScriptPosition &SetLine(size_t line)
ScriptPosition &SetLine(int32_t line)
{
line_ = line;
return *this;
@@ -1022,7 +1016,7 @@ public:
return column_;
}
ScriptPosition &SetColumn(size_t column)
ScriptPosition &SetColumn(int32_t column)
{
column_ = column;
return *this;
@@ -1032,8 +1026,8 @@ private:
NO_COPY_SEMANTIC(ScriptPosition);
NO_MOVE_SEMANTIC(ScriptPosition);
size_t line_ {0};
size_t column_ {0};
int32_t line_ {0};
int32_t column_ {0};
};
// Debugger.SearchMatch
@@ -1048,7 +1042,7 @@ private:
NO_COPY_SEMANTIC(SearchMatch);
NO_MOVE_SEMANTIC(SearchMatch);
size_t lineNumber_ {0};
int32_t lineNumber_ {0};
CString lineContent_ {};
};
@@ -1066,7 +1060,7 @@ public:
return scriptId_;
}
LocationRange &SetScriptId(const ScriptId &scriptId)
LocationRange &SetScriptId(ScriptId scriptId)
{
scriptId_ = scriptId;
return *this;
@@ -1117,7 +1111,7 @@ public:
return scriptId_;
}
BreakLocation &SetScriptId(const ScriptId &scriptId)
BreakLocation &SetScriptId(ScriptId scriptId)
{
scriptId_ = scriptId;
return *this;
@@ -1128,7 +1122,7 @@ public:
return line_;
}
BreakLocation &SetLine(size_t line)
BreakLocation &SetLine(int32_t line)
{
line_ = line;
return *this;
@@ -1139,7 +1133,7 @@ public:
return column_.value_or(-1);
}
BreakLocation &SetColumn(size_t column)
BreakLocation &SetColumn(int32_t column)
{
column_ = column;
return *this;
@@ -1153,9 +1147,9 @@ public:
/*
* @see {#BreakType}
*/
CString GetType() const
const CString &GetType() const
{
return type_.value_or("");
return type_.value();
}
BreakLocation &SetType(const CString &type)
@@ -1193,7 +1187,7 @@ private:
NO_MOVE_SEMANTIC(BreakLocation);
ScriptId scriptId_ {};
size_t line_ {0};
int32_t line_ {0};
std::optional<int32_t> column_ {};
std::optional<CString> type_ {};
};
@@ -1224,7 +1218,7 @@ public:
/*
* @see {#Scope::Type}
*/
CString GetType() const
const CString &GetType() const
{
return type_;
}
@@ -1246,9 +1240,9 @@ public:
return *this;
}
CString GetName() const
const CString &GetName() const
{
return name_.value_or("");
return name_.value();
}
Scope &SetName(const CString &name)
@@ -1374,13 +1368,13 @@ public:
return callFrameId_;
}
CallFrame &SetCallFrameId(const CallFrameId &callFrameId)
CallFrame &SetCallFrameId(CallFrameId callFrameId)
{
callFrameId_ = callFrameId;
return *this;
}
CString GetFunctionName() const
const CString &GetFunctionName() const
{
return functionName_;
}
@@ -1421,7 +1415,7 @@ public:
return *this;
}
CString GetUrl() const
const CString &GetUrl() const
{
return url_;
}
+1 -1
View File
@@ -33,7 +33,7 @@ void UninitializeDebugger()
void DispatchProtocolMessage(const std::string &message)
{
if (g_handler != nullptr) {
g_handler->ProcessCommand(DebuggerApi::ConvertToString(message));
g_handler->ProcessCommand(message.c_str());
}
}
} // namespace panda::tooling::ecmascript
+2 -3
View File
@@ -63,8 +63,7 @@ DispatchRequest::DispatchRequest(const EcmaVM *ecmaVm, const CString &message) :
LOG(ERROR, DEBUGGER) << "method format error";
return;
}
CString wholeMethod =
DebuggerApi::ConvertToString(StringRef::Cast(*methodResult)->ToString());
CString wholeMethod = DebuggerApi::ToCString(methodResult);
CString::size_type length = wholeMethod.length();
CString::size_type indexPoint;
indexPoint = wholeMethod.find_first_of('.', 0);
@@ -106,7 +105,7 @@ DispatchResponse DispatchResponse::Create(std::optional<Error> error)
DispatchResponse response;
if (error.has_value()) {
response.code_ = ResponseCode::NOK;
response.errorMsg_ = DebuggerApi::ConvertToString(error->GetMessage());
response.errorMsg_ = error->GetMessage();
}
return response;
}
+8 -7
View File
@@ -19,15 +19,16 @@
#include <map>
#include <memory>
#include "libpandabase/macros.h"
#include "ecmascript/napi/include/jsnapi.h"
#include "ecmascript/mem/c_containers.h"
#include "ecmascript/mem/c_string.h"
#include "ecmascript/napi/include/jsnapi.h"
#include "include/tooling/debug_interface.h"
#include "libpandabase/macros.h"
namespace panda::tooling::ecmascript {
using panda::ecmascript::CMap;
using panda::ecmascript::CString;
using panda::ecmascript::CUnorderedMap;
class FrontEnd;
class PtBaseReturns;
class PtBaseEvents;
@@ -64,11 +65,11 @@ public:
{
return params_;
}
CString GetDomain() const
const CString &GetDomain() const
{
return domain_;
}
CString GetMethod() const
const CString &GetMethod() const
{
return method_;
}
@@ -101,7 +102,7 @@ public:
return code_;
}
CString GetMessage() const
const CString &GetMessage() const
{
return errorMsg_;
}
@@ -147,7 +148,7 @@ public:
void Dispatch(const DispatchRequest &request);
private:
CMap<CString, std::unique_ptr<DispatcherBase>> dispatchers_ {};
CUnorderedMap<CString, std::unique_ptr<DispatcherBase>> dispatchers_ {};
NO_COPY_SEMANTIC(Dispatcher);
NO_MOVE_SEMANTIC(Dispatcher);
+22 -35
View File
@@ -21,11 +21,12 @@
#include "ecmascript/js_handle.h"
#include "ecmascript/js_method.h"
#include "ecmascript/jspandafile/js_pandafile_manager.h"
#include "ecmascript/mem/c_string.h"
#include "ecmascript/napi/jsnapi_helper-inl.h"
#include "ecmascript/tooling/interface/js_debugger.h"
namespace panda::tooling::ecmascript {
using panda::ecmascript::CStringToL;
using panda::ecmascript::EcmaString;
using panda::ecmascript::JSHandle;
using panda::ecmascript::JSTaggedValue;
using panda::ecmascript::JSNativePointer;
@@ -37,22 +38,6 @@ using panda::ecmascript::base::ALLOW_HEX;
using panda::ecmascript::base::ALLOW_OCTAL;
using panda::ecmascript::base::NumberHelper;
// CString
uint64_t DebuggerApi::CStringToULL(const CString &str)
{
return panda::ecmascript::CStringToULL(str);
}
CString DebuggerApi::ToCString(int32_t number)
{
return panda::ecmascript::ToCString(number);
}
CString DebuggerApi::ConvertToString(const std::string &str)
{
return panda::ecmascript::ConvertToString(str);
}
// InterpretedFrameHandler
uint32_t DebuggerApi::GetStackDepth(const EcmaVM *ecmaVm)
{
@@ -126,6 +111,24 @@ Local<JSValueRef> DebuggerApi::GetVRegValue(const EcmaVM *ecmaVm,
return JSNApiHelper::ToLocal<JSValueRef>(handledValue);
}
CString DebuggerApi::ToCString(Local<JSValueRef> str)
{
ecmascript::JSHandle<ecmascript::JSTaggedValue> ret = JSNApiHelper::ToJSHandle(str);
ASSERT(ret->IsString());
EcmaString *ecmaStr = EcmaString::Cast(ret.GetTaggedValue().GetTaggedObject());
return ConvertToString(ecmaStr);
}
int32_t DebuggerApi::CStringToInt(const CString &str)
{
return CStringToL(str);
}
int32_t DebuggerApi::StringToInt(Local<JSValueRef> str)
{
return CStringToInt(ToCString(str));
}
// JSThread
Local<JSValueRef> DebuggerApi::GetException(const EcmaVM *ecmaVm)
{
@@ -144,22 +147,6 @@ void DebuggerApi::ClearException(const EcmaVM *ecmaVm)
return ecmaVm->GetJSThread()->ClearException();
}
// EcmaVM
const panda_file::File *DebuggerApi::FindPandaFile(const CString &fileName)
{
const panda_file::File *pfs = nullptr;
::panda::ecmascript::JSPandaFileManager::GetInstance()->EnumerateJSPandaFiles([&pfs, fileName](
const panda::ecmascript::JSPandaFile *jsPandaFile) {
if (ConvertToString(jsPandaFile->GetJSPandaFileDesc()) == fileName) {
pfs = jsPandaFile->GetPandaFile();
return false;
}
return true;
});
return pfs;
}
// NumberHelper
double DebuggerApi::StringToDouble(const uint8_t *start, const uint8_t *end, uint8_t radix)
{
@@ -224,7 +211,7 @@ void DebuggerApi::SetProperties(const EcmaVM *ecmaVm, int32_t level, uint32_t sl
LexicalEnv::Cast(env.GetTaggedObject())->SetProperties(ecmaVm->GetJSThread(), slot, target);
}
bool DebuggerApi::EvaluateLexicalValue(const EcmaVM *ecmaVm, const std::string &name, int32_t &level, uint32_t &slot)
bool DebuggerApi::EvaluateLexicalValue(const EcmaVM *ecmaVm, const CString &name, int32_t &level, uint32_t &slot)
{
JSTaggedValue curEnv = ecmaVm->GetJSThread()->GetCurrentLexenv();
for (; curEnv.IsTaggedArray(); curEnv = LexicalEnv::Cast(curEnv.GetTaggedObject())->GetParentEnv()) {
@@ -245,7 +232,7 @@ bool DebuggerApi::EvaluateLexicalValue(const EcmaVM *ecmaVm, const std::string &
return false;
}
Local<JSValueRef> DebuggerApi::GetLexicalValueInfo(const EcmaVM *ecmaVm, const std::string &name)
Local<JSValueRef> DebuggerApi::GetLexicalValueInfo(const EcmaVM *ecmaVm, const CString &name)
{
JSThread *thread = ecmaVm->GetJSThread();
JSTaggedValue curEnv = thread->GetCurrentLexenv();
+7 -10
View File
@@ -56,11 +56,6 @@ enum StackState {
class PUBLIC_API DebuggerApi {
public:
// CString
static uint64_t CStringToULL(const CString &str);
static CString ToCString(int32_t number);
static CString ConvertToString(const std::string &str);
// InterpretedFrameHandler
static uint32_t GetStackDepth(const EcmaVM *ecmaVm);
static bool StackWalker(const EcmaVM *ecmaVm, std::function<StackState(const InterpretedFrameHandler *)> func);
@@ -73,14 +68,16 @@ public:
static Local<JSValueRef> GetVRegValue(const EcmaVM *ecmaVm,
const InterpretedFrameHandler *frameHandler, size_t index);
// String
static int32_t CStringToInt(const CString &str);
static CString ToCString(Local<JSValueRef> str);
static int32_t StringToInt(Local<JSValueRef> str);
// JSThread
static Local<JSValueRef> GetException(const EcmaVM *ecmaVm);
static void SetException(const EcmaVM *ecmaVm, Local<JSValueRef> exception);
static void ClearException(const EcmaVM *ecmaVm);
// EcmaVM
static const panda_file::File *FindPandaFile(const CString &fileName);
// NumberHelper
static double StringToDouble(const uint8_t *start, const uint8_t *end, uint8_t radix);
@@ -97,8 +94,8 @@ public:
// ScopeInfo
static Local<JSValueRef> GetProperties(const EcmaVM *ecmaVm, int32_t level, uint32_t slot);
static void SetProperties(const EcmaVM *ecmaVm, int32_t level, uint32_t slot, Local<JSValueRef> value);
static bool EvaluateLexicalValue(const EcmaVM *ecmaVm, const std::string &name, int32_t &level, uint32_t &slot);
static Local<JSValueRef> GetLexicalValueInfo(const EcmaVM *ecmaVm, const std::string &name);
static bool EvaluateLexicalValue(const EcmaVM *ecmaVm, const CString &name, int32_t &level, uint32_t &slot);
static Local<JSValueRef> GetLexicalValueInfo(const EcmaVM *ecmaVm, const CString &name);
};
} // namespace panda::tooling::ecmascript
+11 -11
View File
@@ -28,21 +28,21 @@ std::optional<Error> JSDebugger::SetBreakpoint(const PtLocation &location)
JSMethod *method = FindMethod(location);
if (method == nullptr) {
return Error(Error::Type::METHOD_NOT_FOUND,
std::string("Cannot find JSMethod with id ") + std::to_string(location.GetMethodId().GetOffset()) +
" in panda file '" + std::string(location.GetPandaFile()) + "'");
"Cannot find JSMethod with id " + std::to_string(location.GetMethodId().GetOffset()) +
" in panda file '" + location.GetPandaFile() + "'");
}
if (location.GetBytecodeOffset() >= method->GetCodeSize()) {
return Error(Error::Type::INVALID_BREAKPOINT, std::string("Invalid breakpoint location: bytecode offset (") +
std::to_string(location.GetBytecodeOffset()) +
") >= JSMethod code size (" +
std::to_string(method->GetCodeSize()) + ")");
return Error(Error::Type::INVALID_BREAKPOINT, "Invalid breakpoint location: bytecode offset (" +
std::to_string(location.GetBytecodeOffset()) +
") >= JSMethod code size (" +
std::to_string(method->GetCodeSize()) + ")");
}
if (!breakpoints_.emplace(method, location.GetBytecodeOffset()).second) {
return Error(Error::Type::BREAKPOINT_ALREADY_EXISTS,
std::string("Breakpoint already exists: bytecode offset ") +
std::to_string(location.GetBytecodeOffset()));
"Breakpoint already exists: bytecode offset " +
std::to_string(location.GetBytecodeOffset()));
}
return {};
@@ -53,8 +53,8 @@ std::optional<Error> JSDebugger::RemoveBreakpoint(const PtLocation &location)
JSMethod *method = FindMethod(location);
if (method == nullptr) {
return Error(Error::Type::METHOD_NOT_FOUND,
std::string("Cannot find JSMethod with id ") + std::to_string(location.GetMethodId().GetOffset()) +
" in panda file '" + std::string(location.GetPandaFile()) + "'");
"Cannot find JSMethod with id " + std::to_string(location.GetMethodId().GetOffset()) +
" in panda file '" + location.GetPandaFile() + "'");
}
if (!RemoveBreakpoint(method, location.GetBytecodeOffset())) {
@@ -143,7 +143,7 @@ JSMethod *JSDebugger::FindMethod(const PtLocation &location) const
JSMethod *method = nullptr;
::panda::ecmascript::JSPandaFileManager::GetInstance()->EnumerateJSPandaFiles([&method, location](
const panda::ecmascript::JSPandaFile *jsPandaFile) {
if (location.GetPandaFile() == jsPandaFile->GetJSPandaFileDesc()) {
if (jsPandaFile->GetJSPandaFileDesc() == location.GetPandaFile()) {
JSMethod *methodsData = jsPandaFile->GetMethods();
uint32_t numberMethods = jsPandaFile->GetNumMethods();
for (uint32_t i = 0; i < numberMethods; ++i) {
@@ -18,7 +18,6 @@
#include "ecmascript/ecma_vm.h"
#include "ecmascript/js_method.h"
#include "ecmascript/mem/c_containers.h"
#include "ecmascript/tooling/interface/debugger_api.h"
#include "tooling/debugger.h"
+1 -1
View File
@@ -88,7 +88,7 @@ CList<PtStepRange> JSPtExtractor::GetStepRanges(File::EntityId methodId, uint32_
{
CList<PtStepRange> ranges {};
auto table = GetLineNumberTable(methodId);
auto callbackFunc = [table, &ranges](size_t line, [[maybe_unused]] size_t column) -> bool {
auto callbackFunc = [table, &ranges](int32_t line, [[maybe_unused]] int32_t column) -> bool {
for (auto it = table.begin(); it != table.end(); ++it) {
auto next = it + 1;
if (it->line == line) {
+5 -5
View File
@@ -19,7 +19,6 @@
#include "ecmascript/js_method.h"
#include "ecmascript/js_thread.h"
#include "ecmascript/jspandafile/debug_info_extractor.h"
#include "ecmascript/mem/c_containers.h"
#include "libpandabase/macros.h"
#include "include/tooling/debug_interface.h"
@@ -28,6 +27,7 @@ using panda::ecmascript::CList;
using panda::ecmascript::DebugInfoExtractor;
using panda::ecmascript::EcmaVM;
using panda::ecmascript::JSMethod;
using panda::ecmascript::JSPandaFile;
using panda::panda_file::File;
class JSPtExtractor : public DebugInfoExtractor {
@@ -60,11 +60,11 @@ public:
Type type_;
};
explicit JSPtExtractor(const File *pf) : DebugInfoExtractor(pf) {}
explicit JSPtExtractor(const JSPandaFile *jsPandaFile) : DebugInfoExtractor(jsPandaFile) {}
virtual ~JSPtExtractor() = default;
template<class Callback>
bool MatchWithLocation(const Callback &cb, size_t line, size_t column)
bool MatchWithLocation(const Callback &cb, int32_t line, int32_t column)
{
auto methods = GetMethodIdList();
for (const auto &method : methods) {
@@ -92,8 +92,8 @@ public:
{
auto lineTable = GetLineNumberTable(methodId);
auto columnTable = GetColumnNumberTable(methodId);
size_t line = 0;
size_t column = 0;
int32_t line = 0;
int32_t column = 0;
for (const auto &pair : lineTable) {
if (offset < pair.offset) {
+2 -2
View File
@@ -53,8 +53,8 @@ void ProtocolHandler::ProcessCommand(const CString &msg)
if (!exception->IsHole()) {
DebuggerApi::SetException(vm_, exception);
}
std::string startDebugging("Runtime.runIfWaitingForDebugger");
if (msg.find(startDebugging, 0) != std::string::npos) {
CString startDebugging("Runtime.runIfWaitingForDebugger");
if (msg.find(startDebugging, 0) != CString::npos) {
waitingForDebugger_ = false;
}
}
-3
View File
@@ -49,9 +49,6 @@ private:
std::unique_ptr<Dispatcher> dispatcher_ {};
bool waitingForDebugger_ {false};
CQueue<CString> msgQueue_ {};
os::memory::Mutex queueLock_;
os::memory::ConditionVariable queueCond_ GUARDED_BY(queueLock_);
const EcmaVM *vm_ {nullptr};
};
} // namespace panda::tooling::ecmascript
@@ -60,9 +60,7 @@ HWTEST_P_L0(DebuggerApiTest, EcmaScriptSuite)
ASSERT_NE(vm, nullptr);
auto [pandaFile, entryPoint] = GetTestEntryPoint(testName);
std::string fileNameStr(pandaFile);
std::string entryStr(entryPoint);
auto res = JSNApi::Execute(vm, fileNameStr, entryStr);
auto res = JSNApi::Execute(vm, pandaFile.c_str(), entryPoint.c_str());
ASSERT_TRUE(res);
}
@@ -92,12 +92,12 @@ HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedCreateTest)
EXPECT_EQ(breakpointResolved, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"location":{"scriptId":"id2","lineNumber":99}}})";
{"location":{"scriptId":"2","lineNumber":99}}})";
breakpointResolved = BreakpointResolved::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(breakpointResolved, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"breakpointId":"00",
"location":{"scriptId":"id2","lineNumber":99}}})";
"location":{"scriptId":"2","lineNumber":99}}})";
breakpointResolved = BreakpointResolved::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(breakpointResolved, nullptr);
}
@@ -109,7 +109,7 @@ HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedToObjectTest)
Local<StringRef> tmpStr = StringRef::NewFromUtf8(ecmaVm, "params");
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"breakpointId":"00",
"location":{"scriptId":"id2","lineNumber":99}}})";
"location":{"scriptId":"2","lineNumber":99}}})";
breakpointResolved = BreakpointResolved::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(breakpointResolved, nullptr);
@@ -123,7 +123,7 @@ HWTEST_F_L0(DebuggerEventsTest, BreakpointResolvedToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("00", Local<StringRef>(result)->ToString());
EXPECT_EQ("00", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "location");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -166,7 +166,7 @@ HWTEST_F_L0(DebuggerEventsTest, PausedCreateTest)
{"callFrames":[)" +
R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":10,"functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})" +
@@ -176,7 +176,7 @@ HWTEST_F_L0(DebuggerEventsTest, PausedCreateTest)
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"callFrames":[)" +
R"({"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}})" +
@@ -193,7 +193,7 @@ HWTEST_F_L0(DebuggerEventsTest, PausedToObjectTest)
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"callFrames":[{"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7",
"location":{"scriptId":"5","lineNumber":19},"url":"url7",
"scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}],
"this":{"type":"object","subtype":"v128"}}],"reason":"exception"}})";
paused = Paused::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
@@ -209,7 +209,7 @@ HWTEST_F_L0(DebuggerEventsTest, PausedToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("exception", Local<StringRef>(result)->ToString());
EXPECT_EQ("exception", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "callFrames");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -230,7 +230,7 @@ HWTEST_F_L0(DebuggerEventsTest, ResumedToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string(resumed->GetName().c_str()), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString(resumed->GetName().c_str()), DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "params");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -265,7 +265,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -276,7 +276,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -286,7 +286,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -295,7 +295,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4}})";
@@ -303,20 +303,20 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0}})";
parse = ScriptFailedToParse::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js"}})";
parse = ScriptFailedToParse::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00"}})";
{"scriptId":"100"}})";
parse = ScriptFailedToParse::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(parse, nullptr);
@@ -332,7 +332,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -346,7 +346,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
"isModule":true,
"length":34,
"stackTrace":{"callFrames":[{"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7",
"location":{"scriptId":"5","lineNumber":19},"url":"url7",
"scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}],
"this":{"type":"object","subtype":"v128"}}]},
"codeOffset":432,
@@ -356,7 +356,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -370,7 +370,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
"isModule":true,
"length":34,
"stackTrace":{"callFrames":[{"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7",
"location":{"scriptId":"5","lineNumber":19},"url":"url7",
"scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}],
"this":{"type":"object","subtype":"v128"}}]},
"codeOffset":432
@@ -379,7 +379,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -393,7 +393,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
"isModule":true,
"length":34,
"stackTrace":{"callFrames":[{"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7",
"location":{"scriptId":"5","lineNumber":19},"url":"url7",
"scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}],
"this":{"type":"object","subtype":"v128"}}]}
}})";
@@ -401,7 +401,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -419,7 +419,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -436,7 +436,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -452,7 +452,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -467,7 +467,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -481,7 +481,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -494,7 +494,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
ASSERT_NE(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -508,7 +508,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseCreateTest)
"isModule":true,
"length":34,
"stackTrace":{"callFrames":[{"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7",
"location":{"scriptId":"5","lineNumber":19},"url":"url7",
"scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}],
"this":{"type":"object","subtype":"v128"}}]},
"codeOffset":432,
@@ -526,7 +526,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest)
Local<StringRef> tmpStr = StringRef::NewFromUtf8(ecmaVm, "params");
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -540,7 +540,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest)
"isModule":true,
"length":34,
"stackTrace":{"callFrames":[{"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7",
"location":{"scriptId":"5","lineNumber":19},"url":"url7",
"scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}],
"this":{"type":"object","subtype":"v128"}}]},
"codeOffset":432,
@@ -560,13 +560,13 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("00", Local<StringRef>(result)->ToString());
EXPECT_EQ("100", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "url");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("use/test.js", Local<StringRef>(result)->ToString());
EXPECT_EQ("use/test.js", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLine");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -602,7 +602,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("hash0001", Local<StringRef>(result)->ToString());
EXPECT_EQ("hash0001", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextAuxData");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -614,7 +614,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("usr/", Local<StringRef>(result)->ToString());
EXPECT_EQ("usr/", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "hasSourceURL");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -644,13 +644,13 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptFailedToParseToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("JavaScript", Local<StringRef>(result)->ToString());
EXPECT_EQ("JavaScript", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "embedderName");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("hh", Local<StringRef>(result)->ToString());
EXPECT_EQ("hh", DebuggerApi::ToCString(result));
}
HWTEST_F_L0(DebuggerEventsTest, ScriptParsedCreateTest)
@@ -679,7 +679,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -690,7 +690,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -700,7 +700,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -709,7 +709,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4}})";
@@ -717,20 +717,20 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0}})";
parse = ScriptParsed::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js"}})";
parse = ScriptParsed::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00"}})";
{"scriptId":"100"}})";
parse = ScriptParsed::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(parse, nullptr);
@@ -746,7 +746,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedCreateTest)
EXPECT_EQ(parse, nullptr);
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"100",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -761,7 +761,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedCreateTest)
"isModule":true,
"length":34,
"stackTrace":{"callFrames":[{"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7",
"location":{"scriptId":"5","lineNumber":19},"url":"url7",
"scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}],
"this":{"type":"object","subtype":"v128"}}]},
"codeOffset":432,
@@ -779,7 +779,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest)
Local<StringRef> tmpStr = StringRef::NewFromUtf8(ecmaVm, "params");
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":
{"scriptId":"00",
{"scriptId":"10",
"url":"use/test.js",
"startLine":0,
"startColumn":4,
@@ -794,7 +794,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest)
"isModule":true,
"length":34,
"stackTrace":{"callFrames":[{"callFrameId":"10","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7",
"location":{"scriptId":"5","lineNumber":19},"url":"url7",
"scopeChain":[{"type":"global","object":{"type":"object"}}, {"type":"local","object":{"type":"object"}}],
"this":{"type":"object","subtype":"v128"}}]},
"codeOffset":432,
@@ -814,13 +814,13 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("00", Local<StringRef>(result)->ToString());
EXPECT_EQ("10", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "url");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("use/test.js", Local<StringRef>(result)->ToString());
EXPECT_EQ("use/test.js", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLine");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -856,7 +856,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("hash0001", Local<StringRef>(result)->ToString());
EXPECT_EQ("hash0001", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextAuxData");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -874,7 +874,7 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("usr/", Local<StringRef>(result)->ToString());
EXPECT_EQ("usr/", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "hasSourceURL");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
@@ -904,12 +904,12 @@ HWTEST_F_L0(DebuggerEventsTest, ScriptParsedToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("JavaScript", Local<StringRef>(result)->ToString());
EXPECT_EQ("JavaScript", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "embedderName");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("hh", Local<StringRef>(result)->ToString());
EXPECT_EQ("hh", DebuggerApi::ToCString(result));
}
} // namespace panda::test
@@ -64,23 +64,23 @@ protected:
HWTEST_F_L0(DebuggerReturnsTest, EnableReturnsToObjectTest)
{
std::unique_ptr<EnableReturns> enableReturns = std::make_unique<EnableReturns>("100");
std::unique_ptr<EnableReturns> enableReturns = std::make_unique<EnableReturns>(100U);
ASSERT_NE(enableReturns, nullptr);
Local<ObjectRef> enableObject = enableReturns->ToObject(ecmaVm);
Local<StringRef> tmpStr = StringRef::NewFromUtf8(ecmaVm, "debuggerId");
ASSERT_TRUE(enableObject->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = enableObject->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string("100"), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString("100"), DebuggerApi::ToCString(result));
}
HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointByUrlReturnsToObjectTest)
{
auto locations = CVector<std::unique_ptr<Location>>();
std::unique_ptr<Location> location = std::make_unique<Location>();
location->SetScriptId("id_1");
location->SetScriptId(1);
locations.emplace_back(std::move(location));
ASSERT_EQ(locations.back()->GetScriptId(), "id_1");
ASSERT_EQ(locations.back()->GetScriptId(), 1U);
std::unique_ptr<SetBreakpointByUrlReturns> setBreakpointByUrlReturns
= std::make_unique<SetBreakpointByUrlReturns>("11", std::move(locations));
@@ -90,7 +90,7 @@ HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointByUrlReturnsToObjectTest)
ASSERT_TRUE(setObject->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = setObject->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string("11"), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString("11"), DebuggerApi::ToCString(result));
}
HWTEST_F_L0(DebuggerReturnsTest, EvaluateOnCallFrameReturnsToObjectTest)
@@ -138,13 +138,13 @@ HWTEST_F_L0(DebuggerReturnsTest, GetScriptSourceReturnsToObjectTest)
ASSERT_TRUE(scriptObject->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = scriptObject->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string("source_1"), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString("source_1"), DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "bytecode");
ASSERT_TRUE(scriptObject->Has(ecmaVm, tmpStr));
result = scriptObject->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string("bytecode_1"), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString("bytecode_1"), DebuggerApi::ToCString(result));
}
HWTEST_F_L0(DebuggerReturnsTest, RestartFrameReturnsToObjectTest)
@@ -172,7 +172,7 @@ HWTEST_F_L0(DebuggerReturnsTest, SetBreakpointReturnsToObjectTest)
ASSERT_TRUE(breakObject->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = breakObject->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string("breakpointId_1"), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString("breakpointId_1"), DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "actualLocation");
ASSERT_TRUE(breakObject->Has(ecmaVm, tmpStr));
@@ -191,7 +191,7 @@ HWTEST_F_L0(DebuggerReturnsTest, SetInstrumentationBreakpointReturnsToObjectTest
ASSERT_TRUE(instrumentationObject->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = instrumentationObject->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string("111"), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString("111"), DebuggerApi::ToCString(result));
}
HWTEST_F_L0(DebuggerReturnsTest, SetScriptSourceReturnsToObjectTest)
@@ -209,8 +209,8 @@ HWTEST_F_L0(DebuggerReturnsTest, SetScriptSourceReturnsToObjectTest)
ASSERT_TRUE(result->IsArray(ecmaVm));
ASSERT_NE(setScriptSourceReturns, nullptr);
exceptionDetails->SetScriptId("id_5");
ASSERT_EQ(exceptionDetails->GetScriptId(), "id_5");
exceptionDetails->SetScriptId(5);
ASSERT_EQ(exceptionDetails->GetScriptId(), 5U);
}
HWTEST_F_L0(DebuggerReturnsTest, GetPropertiesReturnsToObjectTest)
@@ -221,8 +221,8 @@ HWTEST_F_L0(DebuggerReturnsTest, GetPropertiesReturnsToObjectTest)
std::unique_ptr<GetPropertiesReturns> getPropertiesReturns = std::make_unique
<GetPropertiesReturns>(std::move(descriptor));
ASSERT_NE(getPropertiesReturns, nullptr);
exceptionDetails->SetScriptId("id_6");
ASSERT_EQ(exceptionDetails->GetScriptId(), "id_6");
exceptionDetails->SetScriptId(6);
ASSERT_EQ(exceptionDetails->GetScriptId(), 6U);
Local<ArrayRef> getObject = getPropertiesReturns->ToObject(ecmaVm);
Local<StringRef> tmpStr = StringRef::NewFromUtf8(ecmaVm, "result");
@@ -62,8 +62,8 @@ protected:
HWTEST_F_L0(DebuggerScriptTest, ScriptIdTest)
{
std::unique_ptr<PtScript> script = std::make_unique<PtScript>(1, "name_1", "url_1", "source_1");
script->SetScriptId("id_100");
ASSERT_EQ(script->GetScriptId(), "id_100");
script->SetScriptId(100);
ASSERT_EQ(script->GetScriptId(), 100U);
}
HWTEST_F_L0(DebuggerScriptTest, FileNameTest)
+119 -119
View File
@@ -178,7 +178,7 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest)
ASSERT_NE(remoteObject, nullptr);
EXPECT_EQ(ObjectType::Object, remoteObject->GetType());
ASSERT_TRUE(remoteObject->HasValue());
EXPECT_EQ("Test", Local<StringRef>(remoteObject->GetValue())->ToString());
EXPECT_EQ("Test", DebuggerApi::ToCString(remoteObject->GetValue()));
// abnormal params of params.sub-key = [ type = "object", unserializableValue = 100]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object +
@@ -236,12 +236,12 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectCreateTest)
// normal params of params.sub-key = [ type = "object", objectId = "id_1"]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object +
R"(","objectId":"id_1"}})";
R"(","objectId":"1"}})";
remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(remoteObject, nullptr);
EXPECT_EQ(ObjectType::Object, remoteObject->GetType());
ASSERT_TRUE(remoteObject->HasObjectId());
EXPECT_EQ("id_1", remoteObject->GetObjectId());
EXPECT_EQ(1U, remoteObject->GetObjectId());
}
HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest)
@@ -253,7 +253,7 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest)
msg =
CString() + R"({"id":0,"method":"Debugger.Test","params":{"type":")" + ObjectType::Object + R"(","subtype":")" +
ObjectSubType::Array +
R"(","className":"TestClass","value":100,"unserializableValue":"Test","description":"Test","objectId":"id_1"}})";
R"(","className":"TestClass","value":100,"unserializableValue":"Test","description":"Test","objectId":"1"}})";
remoteObject = RemoteObject::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(remoteObject, nullptr);
Local<ObjectRef> object = remoteObject->ToObject(ecmaVm);
@@ -262,17 +262,17 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Array.c_str()), Local<StringRef>(result)->ToString());
EXPECT_EQ(CString(ObjectSubType::Array.c_str()), DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "className");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("TestClass", Local<StringRef>(result)->ToString());
EXPECT_EQ("TestClass", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "value");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -282,17 +282,17 @@ HWTEST_F_L0(DebuggerTypesTest, RemoteObjectToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("Test", Local<StringRef>(result)->ToString());
EXPECT_EQ("Test", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "description");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("Test", Local<StringRef>(result)->ToString());
EXPECT_EQ("Test", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "objectId");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("id_1", Local<StringRef>(result)->ToString());
EXPECT_EQ("1", DebuggerApi::ToCString(result));
}
HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest)
@@ -395,14 +395,14 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsCreateTest)
// normal params of params.sub-key =
// [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"scriptId"="id0"]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":"id0"}})";
"exceptionId":3,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":"0"}})";
exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(exceptionMetaData, nullptr);
EXPECT_EQ(exceptionMetaData->GetExceptionId(), 3);
EXPECT_EQ("text0", exceptionMetaData->GetText());
EXPECT_EQ(exceptionMetaData->GetLine(), 10);
EXPECT_EQ(exceptionMetaData->GetColumn(), 20);
EXPECT_EQ("id0", exceptionMetaData->GetScriptId());
EXPECT_EQ(0U, exceptionMetaData->GetScriptId());
// abnormal params of params.sub-key =
// [exceptionId=3,"text"="text0","lineNumber"=10,"columnNumber"=20,"url"=10]
@@ -494,7 +494,7 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest)
Local<StringRef> tmpStr;
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"exceptionId":5,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":"ScriptId0","url":"url0",
"exceptionId":5,"text":"text0","lineNumber":10,"columnNumber":20,"scriptId":"100","url":"url0",
"exception":{"type":")" +
ObjectType::Object + R"(","subtype":")" + ObjectSubType::Error + R"("},"executionContextId":30}})";
exceptionMetaData = ExceptionDetails::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
@@ -510,7 +510,7 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("text0", Local<StringRef>(result)->ToString());
EXPECT_EQ("text0", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -525,12 +525,12 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("ScriptId0", Local<StringRef>(result)->ToString());
EXPECT_EQ("100", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "url");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("url0", Local<StringRef>(result)->ToString());
EXPECT_EQ("url0", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "exception");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -540,12 +540,12 @@ HWTEST_F_L0(DebuggerTypesTest, ExceptionDetailsToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
Local<JSValueRef> subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Error.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::Error.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "executionContextId");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -659,7 +659,7 @@ HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("name8", Local<StringRef>(result)->ToString());
EXPECT_EQ("name8", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "value");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -669,12 +669,12 @@ HWTEST_F_L0(DebuggerTypesTest, InternalPropertyDescriptorToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
Local<JSValueRef> subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Map.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::Map.c_str()), DebuggerApi::ToCString(subResult));
}
HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorCreateTest)
@@ -927,7 +927,7 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("name8", Local<StringRef>(result)->ToString());
EXPECT_EQ("name8", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "value");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -937,12 +937,12 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
Local<JSValueRef> subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Map.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::Map.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "writable");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -957,12 +957,12 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Regexp.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::Regexp.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "set");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -972,12 +972,12 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Generator.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::Generator.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "configurable");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -1007,12 +1007,12 @@ HWTEST_F_L0(DebuggerTypesTest, PropertyDescriptorToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Proxy.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::Proxy.c_str()), DebuggerApi::ToCString(subResult));
}
HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest)
@@ -1054,44 +1054,44 @@ HWTEST_F_L0(DebuggerTypesTest, LocationCreateTest)
location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(location, nullptr);
// abnormal params of params.sub-key=["scriptId":"id222","lineNumber":"99"]
// abnormal params of params.sub-key=["scriptId":"222","lineNumber":"99"]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":"99"
"scriptId":"222","lineNumber":"99"
}})";
location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(location, nullptr);
// abnormal params of params.sub-key=["scriptId":"id222","lineNumber":[99]]
// abnormal params of params.sub-key=["scriptId":"222","lineNumber":[99]]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":[99]
"scriptId":"222","lineNumber":[99]
}})";
location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(location, nullptr);
// abnormal params of params.sub-key=["scriptId":"id2","lineNumber":99,"columnNumber":"18"]
// abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18"]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":899,"columnNumber":"18"
"scriptId":"222","lineNumber":899,"columnNumber":"18"
}})";
location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(location, nullptr);
// normal params of params.sub-key=["scriptId":"id2","lineNumber":99,"columnNumber":138]
// normal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":138]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":899,"columnNumber":138
"scriptId":"222","lineNumber":899,"columnNumber":138
}})";
location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(location, nullptr);
EXPECT_EQ("id222", location->GetScriptId());
EXPECT_EQ(222U, location->GetScriptId());
EXPECT_EQ(location->GetLine(), 899);
EXPECT_EQ(location->GetColumn(), 138);
// normal params of params.sub-key=["scriptId":"id2122","lineNumber":8299]
// normal params of params.sub-key=["scriptId":"2122","lineNumber":8299]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id2122","lineNumber":8299
"scriptId":"2122","lineNumber":8299
}})";
location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(location, nullptr);
EXPECT_EQ("id2122", location->GetScriptId());
EXPECT_EQ(2122U, location->GetScriptId());
EXPECT_EQ(location->GetLine(), 8299);
}
@@ -1102,7 +1102,7 @@ HWTEST_F_L0(DebuggerTypesTest, LocationToObjectTest)
Local<StringRef> tmpStr;
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id2","lineNumber":99,"columnNumber":18
"scriptId":"2","lineNumber":99,"columnNumber":18
}})";
location = Location::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(location, nullptr);
@@ -1112,7 +1112,7 @@ HWTEST_F_L0(DebuggerTypesTest, LocationToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("id2", Local<StringRef>(result)->ToString());
EXPECT_EQ("2", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -1164,59 +1164,59 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationCreateTest)
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(breakLocation, nullptr);
// abnormal params of params.sub-key=["scriptId":"id222","lineNumber":"99"]
// abnormal params of params.sub-key=["scriptId":"222","lineNumber":"99"]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":"99"
"scriptId":"222","lineNumber":"99"
}})";
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(breakLocation, nullptr);
// abnormal params of params.sub-key=["scriptId":"id222","lineNumber":[99]]
// abnormal params of params.sub-key=["scriptId":"222","lineNumber":[99]]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":[99]
"scriptId":"222","lineNumber":[99]
}})";
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(breakLocation, nullptr);
// abnormal params of params.sub-key=["scriptId":"id2","lineNumber":99,"columnNumber":"18"]
// abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18"]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":899,"columnNumber":"18"
"scriptId":"222","lineNumber":899,"columnNumber":"18"
}})";
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(breakLocation, nullptr);
// abnormal params of params.sub-key=["scriptId":"id2","lineNumber":99,"columnNumber":"18","type":10]
// abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18","type":10]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":899,"columnNumber":"18","type":10
"scriptId":"222","lineNumber":899,"columnNumber":"18","type":10
}})";
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(breakLocation, nullptr);
// abnormal params of params.sub-key=["scriptId":"id2","lineNumber":99,"columnNumber":"18","type":"ee"]
// abnormal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":"18","type":"ee"]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":899,"columnNumber":"18","type":"ee"
"scriptId":"222","lineNumber":899,"columnNumber":"18","type":"ee"
}})";
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
EXPECT_EQ(breakLocation, nullptr);
// normal params of params.sub-key=["scriptId":"id2","lineNumber":99,"columnNumber":138,"type":"return"]
// normal params of params.sub-key=["scriptId":"2","lineNumber":99,"columnNumber":138,"type":"return"]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id222","lineNumber":899,"columnNumber":138,"type":"return"
"scriptId":"222","lineNumber":899,"columnNumber":138,"type":"return"
}})";
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(breakLocation, nullptr);
EXPECT_EQ("id222", breakLocation->GetScriptId());
EXPECT_EQ(222U, breakLocation->GetScriptId());
EXPECT_EQ(breakLocation->GetLine(), 899);
EXPECT_EQ(breakLocation->GetColumn(), 138);
EXPECT_EQ("return", breakLocation->GetType());
// normal params of params.sub-key=["scriptId":"id2122","lineNumber":8299]
// normal params of params.sub-key=["scriptId":"2122","lineNumber":8299]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id2122","lineNumber":8299
"scriptId":"2122","lineNumber":8299
}})";
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(breakLocation, nullptr);
EXPECT_EQ("id2122", breakLocation->GetScriptId());
EXPECT_EQ(2122U, breakLocation->GetScriptId());
EXPECT_EQ(breakLocation->GetLine(), 8299);
}
@@ -1227,7 +1227,7 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationToObjectTest)
Local<StringRef> tmpStr;
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"scriptId":"id12","lineNumber":919,"columnNumber":148,"type":"call"
"scriptId":"12","lineNumber":919,"columnNumber":148,"type":"call"
}})";
breakLocation = BreakLocation::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(breakLocation, nullptr);
@@ -1237,7 +1237,7 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("id12", Local<StringRef>(result)->ToString());
EXPECT_EQ("12", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -1252,7 +1252,7 @@ HWTEST_F_L0(DebuggerTypesTest, BreakLocationToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("call", Local<StringRef>(result)->ToString());
EXPECT_EQ("call", DebuggerApi::ToCString(result));
}
HWTEST_F_L0(DebuggerTypesTest, ScopeCreateTest)
@@ -1378,8 +1378,8 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest)
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"type":"global","object":{"type":")" +
ObjectType::Object + R"(","subtype":")" + ObjectSubType::Dataview + R"("},"name":"name9",
"startLocation":{"scriptId":"id2","lineNumber":99},
"endLocation":{"scriptId":"id13","lineNumber":146}
"startLocation":{"scriptId":"2","lineNumber":99},
"endLocation":{"scriptId":"13","lineNumber":146}
}})";
scope = Scope::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(scope, nullptr);
@@ -1389,7 +1389,7 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("global", Local<StringRef>(result)->ToString());
EXPECT_EQ("global", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "object");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -1399,17 +1399,17 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
Local<JSValueRef> subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Dataview.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::Dataview.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "name");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("name9", Local<StringRef>(result)->ToString());
EXPECT_EQ("name9", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "startLocation");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -1419,7 +1419,7 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ("id2", Local<StringRef>(subResult)->ToString());
EXPECT_EQ("2", DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
@@ -1434,7 +1434,7 @@ HWTEST_F_L0(DebuggerTypesTest, ScopeToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ("id13", Local<StringRef>(subResult)->ToString());
EXPECT_EQ("13", DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
@@ -1470,7 +1470,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":10,"functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1479,8 +1479,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":["id0"],"functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":["0"],"functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1489,8 +1489,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":10,
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":10,
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1499,8 +1499,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":["name0"],
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":["name0"],
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1509,8 +1509,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0","functionLocation":10,
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0","functionLocation":10,
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1519,8 +1519,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0","functionLocation":{"scriptId11":"id5","lineNumber":19},
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0","functionLocation":{"scriptId11":"id5","lineNumber":19},
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1529,7 +1529,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"callFrameId":"0","functionName":"name0",
"location":{"scriptId2":"id5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
@@ -1539,7 +1539,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"callFrameId":"0","functionName":"name0",
"location":10,"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
@@ -1549,8 +1549,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":10,"scopeChain":
"callFrameId":"0","functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":10,"scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1559,8 +1559,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":{"url":"url7"},"scopeChain":
"callFrameId":"0","functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":{"url":"url7"},"scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1569,7 +1569,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0", "location":{"scriptId":"id5","lineNumber":19},
"callFrameId":"0","functionName":"name0", "location":{"scriptId":"5","lineNumber":19},
"url":"url7","scopeChain":10,"this":{"type":")" +
ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
@@ -1577,8 +1577,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
{"type":"22","object":{"type":")" +
ObjectType::Object + R"("}},"this":{"type":")" + ObjectType::Object + R"(","subtype":")" +
ObjectSubType::V128 + R"("}}})";
@@ -1587,8 +1587,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":10}})";
@@ -1597,8 +1597,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"11":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
@@ -1607,8 +1607,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("},
@@ -1618,8 +1618,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// abnormal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("},
@@ -1629,18 +1629,18 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// normal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0",
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0",
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 + R"("}}})";
callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(callFrame, nullptr);
EXPECT_EQ("id0", callFrame->GetCallFrameId());
EXPECT_EQ(0U, callFrame->GetCallFrameId());
EXPECT_EQ("name0", callFrame->GetFunctionName());
ASSERT_FALSE(callFrame->HasFunctionLocation());
Location *location = callFrame->GetLocation();
EXPECT_EQ("id5", location->GetScriptId());
EXPECT_EQ(5U, location->GetScriptId());
EXPECT_EQ(location->GetLine(), 19);
EXPECT_EQ("url7", callFrame->GetUrl());
const CVector<std::unique_ptr<Scope>> *scopeChain = callFrame->GetScopeChain();
@@ -1653,21 +1653,21 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameCreateTest)
// normal params of params.sub-key=[..]
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0","functionLocation":{"scriptId":"id3","lineNumber":16},
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"10","functionName":"name0","functionLocation":{"scriptId":"3","lineNumber":16},
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::V128 +
R"("},"returnValue":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::I32 + R"("}}})";
callFrame = CallFrame::Create(ecmaVm, DispatchRequest(ecmaVm, msg).GetParams());
ASSERT_NE(callFrame, nullptr);
EXPECT_EQ("id0", callFrame->GetCallFrameId());
EXPECT_EQ(10U, callFrame->GetCallFrameId());
EXPECT_EQ("name0", callFrame->GetFunctionName());
Location *functionLocation = callFrame->GetFunctionLocation();
EXPECT_EQ("id3", functionLocation->GetScriptId());
EXPECT_EQ(3U, functionLocation->GetScriptId());
EXPECT_EQ(functionLocation->GetLine(), 16);
location = callFrame->GetLocation();
EXPECT_EQ("id5", location->GetScriptId());
EXPECT_EQ(5U, location->GetScriptId());
EXPECT_EQ(location->GetLine(), 19);
EXPECT_EQ("url7", callFrame->GetUrl());
scopeChain = callFrame->GetScopeChain();
@@ -1689,8 +1689,8 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest)
Local<StringRef> tmpStr;
msg = CString() + R"({"id":0,"method":"Debugger.Test","params":{
"callFrameId":"id0","functionName":"name0","functionLocation":{"scriptId":"id3","lineNumber":16},
"location":{"scriptId":"id5","lineNumber":19},"url":"url7","scopeChain":
"callFrameId":"0","functionName":"name0","functionLocation":{"scriptId":"3","lineNumber":16},
"location":{"scriptId":"5","lineNumber":19},"url":"url7","scopeChain":
[{"type":"global","object":{"type":")" +
ObjectType::Object + R"("}}, {"type":"local","object":{"type":")" + ObjectType::Object +
R"("}}],"this":{"type":")" + ObjectType::Object + R"(","subtype":")" + ObjectSubType::Iterator +
@@ -1703,12 +1703,12 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
Local<JSValueRef> result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("id0", Local<StringRef>(result)->ToString());
EXPECT_EQ("0", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "functionName");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("name0", Local<StringRef>(result)->ToString());
EXPECT_EQ("name0", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "functionLocation");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -1718,7 +1718,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
Local<JSValueRef> subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ("id3", Local<StringRef>(subResult)->ToString());
EXPECT_EQ("3", DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
@@ -1733,7 +1733,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ("id5", Local<StringRef>(subResult)->ToString());
EXPECT_EQ("5", DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "lineNumber");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
@@ -1743,7 +1743,7 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest)
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!result.IsEmpty() && !result->IsUndefined());
EXPECT_EQ("url7", Local<StringRef>(result)->ToString());
EXPECT_EQ("url7", DebuggerApi::ToCString(result));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "scopeChain");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -1760,12 +1760,12 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::Iterator.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::Iterator.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "returnValue");
ASSERT_TRUE(object->Has(ecmaVm, tmpStr));
result = object->Get(ecmaVm, tmpStr);
@@ -1775,11 +1775,11 @@ HWTEST_F_L0(DebuggerTypesTest, CallFrameToObjectTest)
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectType::Object.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectType::Object.c_str()), DebuggerApi::ToCString(subResult));
tmpStr = StringRef::NewFromUtf8(ecmaVm, "subtype");
ASSERT_TRUE(Local<ObjectRef>(result)->Has(ecmaVm, Local<JSValueRef>(tmpStr)));
subResult = Local<ObjectRef>(result)->Get(ecmaVm, tmpStr);
ASSERT_TRUE(!subResult.IsEmpty() && !subResult->IsUndefined());
EXPECT_EQ(std::string(ObjectSubType::I64.c_str()), Local<StringRef>(subResult)->ToString());
EXPECT_EQ(CString(ObjectSubType::I64.c_str()), DebuggerApi::ToCString(subResult));
}
} // namespace panda::test
+1 -1
View File
@@ -371,7 +371,7 @@ HWTEST_F_L0(JSPtHooksTest, ExceptionRevokedTest)
{
auto backend = std::make_unique<JSBackend>(ecmaVm);
std::unique_ptr<JSPtHooks>jspthooks = std::make_unique<JSPtHooks>(backend.get());
jspthooks->ExceptionRevoked(std::string(), panda_file::File::EntityId());
jspthooks->ExceptionRevoked("", panda_file::File::EntityId());
ASSERT_NE(jspthooks, nullptr);
}
@@ -42,7 +42,7 @@ std::pair<EntityId, uint32_t> TestExtractor::GetBreakpointAddress(const SourceLo
SourceLocation TestExtractor::GetSourceLocation(EntityId methodId, uint32_t bytecodeOffset)
{
SourceLocation location {GetSourceFile(methodId), 0, 0};
auto callbackFunc = [&location](size_t line, size_t column) -> bool {
auto callbackFunc = [&location](int32_t line, int32_t column) -> bool {
location.line = line;
location.column = column;
return true;
@@ -16,19 +16,17 @@
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EXTRACTOR_H
#define ECMASCRIPT_TOOLING_TEST_UTILS_TEST_EXTRACTOR_H
#include "ecmascript/mem/c_string.h"
#include "ecmascript/tooling/js_pt_extractor.h"
namespace panda::tooling::ecmascript::test {
using EntityId = panda_file::File::EntityId;
using panda::ecmascript::CString;
using panda::tooling::ecmascript::JSPtExtractor;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
struct SourceLocation {
CString path; // NOLINT(misc-non-private-member-variables-in-classes)
size_t line; // NOLINT(misc-non-private-member-variables-in-classes)
size_t column;
int32_t line; // NOLINT(misc-non-private-member-variables-in-classes)
int32_t column;
bool operator==(const SourceLocation &other) const
{
@@ -43,7 +41,7 @@ struct SourceLocation {
class TestExtractor : public JSPtExtractor {
public:
explicit TestExtractor(const panda_file::File *pandaFileData) : JSPtExtractor(pandaFileData) {}
explicit TestExtractor(const JSPandaFile *pandaFile) : JSPtExtractor(pandaFile) {}
~TestExtractor() = default;
std::pair<EntityId, uint32_t> GetBreakpointAddress(const SourceLocation &sourceLocation);
+8 -10
View File
@@ -16,7 +16,7 @@
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TEST_UTIL_H
#define ECMASCRIPT_TOOLING_TEST_UTILS_TEST_UTIL_H
#include "ecmascript/mem/c_containers.h"
#include "ecmascript/jspandafile/js_pandafile_manager.h"
#include "ecmascript/tooling/interface/js_debugger.h"
#include "ecmascript/tooling/test/utils/test_events.h"
#include "ecmascript/tooling/test/utils/test_extractor.h"
@@ -123,26 +123,24 @@ public:
return lastEvent_ == DebugEvent::VM_DEATH;
}
static PtLocation GetLocation(const char *sourceFile, size_t line, size_t column, const char *pandaFile)
static PtLocation GetLocation(const char *sourceFile, int32_t line, int32_t column, const char *pandaFile)
{
std::unique_ptr<const panda_file::File> uFile = panda_file::File::Open(pandaFile);
const panda_file::File *pf = uFile.get();
if (pf == nullptr) {
auto jsPandaFile = ::panda::ecmascript::JSPandaFileManager::GetInstance()->OpenJSPandaFile(pandaFile);
if (jsPandaFile == nullptr) {
return PtLocation("", EntityId(0), 0);
}
TestExtractor extractor(pf);
TestExtractor extractor(jsPandaFile);
auto [id, offset] = extractor.GetBreakpointAddress({sourceFile, line, column});
return PtLocation(pandaFile, id, offset);
}
static SourceLocation GetSourceLocation(const PtLocation &location, const char *pandaFile)
{
std::unique_ptr<const panda_file::File> uFile = panda_file::File::Open(pandaFile);
const panda_file::File *pf = uFile.get();
if (pf == nullptr) {
auto jsPandaFile = ::panda::ecmascript::JSPandaFileManager::GetInstance()->OpenJSPandaFile(pandaFile);
if (jsPandaFile == nullptr) {
return SourceLocation();
}
TestExtractor extractor(pf);
TestExtractor extractor(jsPandaFile);
return extractor.GetSourceLocation(location.GetMethodId(), location.GetBytecodeOffset());
}
@@ -16,7 +16,6 @@
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_JS_BREAKPOINT_TEST_H
#define ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_JS_BREAKPOINT_TEST_H
#include "ecmascript/mem/c_string.h"
#include "ecmascript/tooling/test/utils/test_util.h"
namespace panda::tooling::ecmascript::test {
@@ -16,7 +16,6 @@
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_JS_EXCEPTION_TEST_H
#define ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_JS_EXCEPTION_TEST_H
#include "ecmascript/mem/c_string.h"
#include "ecmascript/tooling/test/utils/test_util.h"
namespace panda::tooling::ecmascript::test {
@@ -33,10 +33,10 @@ static void RegisterTests()
TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsBreakpointTest", GetJsBreakpointTest());
}
std::vector<const char *> GetTestList(panda_file::SourceLang language)
CVector<const char *> GetTestList(panda_file::SourceLang language)
{
RegisterTests();
std::vector<const char *> res;
CVector<const char *> res;
auto &tests = TestUtil::GetTests();
auto languageIt = tests.find(language);
if (languageIt == tests.end()) {
@@ -19,13 +19,15 @@
#include <utility>
#include <vector>
#include "ecmascript/mem/c_containers.h"
#include "ecmascript/mem/c_string.h"
#include "libpandafile/file_items.h"
namespace panda::tooling::ecmascript::test {
using panda::ecmascript::CString;
using panda::ecmascript::CVector;
std::vector<const char *> GetTestList(panda_file::SourceLang language);
CVector<const char *> GetTestList(panda_file::SourceLang language);
void SetCurrentTestName(const char *testName);
const char *GetCurrentTestName();
+1 -1
View File
@@ -25,7 +25,7 @@ void TSLoader::DecodeTSTypes(const JSPandaFile *jsPandaFile)
ObjectFactory *factory = vm_->GetFactory();
JSHandle<TSModuleTable> table = GetTSModuleTable();
JSHandle<EcmaString> queryFileName = factory->NewFromStdString(jsPandaFile->GetJSPandaFileDesc());
JSHandle<EcmaString> queryFileName = factory->NewFromString(jsPandaFile->GetJSPandaFileDesc());
int index = table->GetGlobalModuleID(thread, queryFileName);
if (index == TSModuleTable::NOT_FOUND) {
CVector<JSHandle<EcmaString>> recordImportModules {};
+2 -2
View File
@@ -33,7 +33,7 @@ void TSTypeTable::Initialize(JSThread *thread, const JSPandaFile *jsPandaFile,
JSHandle<TSTypeTable> tsTypetable = GenerateTypeTable(thread, jsPandaFile, recordImportModules);
// Set TStypeTable -> GlobleModuleTable
JSHandle<EcmaString> fileName = factory->NewFromStdString(jsPandaFile->GetJSPandaFileDesc());
JSHandle<EcmaString> fileName = factory->NewFromString(jsPandaFile->GetJSPandaFileDesc());
tsLoader->AddTypeTable(JSHandle<JSTaggedValue>(tsTypetable), fileName);
// management dependency module
@@ -63,7 +63,7 @@ JSHandle<TSTypeTable> TSTypeTable::GenerateTypeTable(JSThread *thread, const JSP
JSHandle<TSTypeTable> table = factory->NewTSTypeTable(length);
JSMutableHandle<TaggedArray> typeLiteral(thread, JSTaggedValue::Undefined());
JSHandle<EcmaString> fileName = factory->NewFromStdString(jsPandaFile->GetJSPandaFileDesc());
JSHandle<EcmaString> fileName = factory->NewFromString(jsPandaFile->GetJSPandaFileDesc());
for (; idx <= length; ++idx) {
typeLiteral.Update(LiteralDataExtractor::GetDatasIgnoreType(thread, jsPandaFile, idx).GetTaggedValue());
JSHandle<JSTaggedValue> type = ParseType(thread, table, typeLiteral, fileName, recordImportModules);