mirror of
https://gitee.com/openharmony/arkcompiler_toolchain
synced 2024-11-23 15:40:03 +00:00
Fix arkdb tool leak of memory alert
Issue: IALT9Z Signed-off-by: bigtea <tianqushen@huawei.com>
This commit is contained in:
parent
5b040b7072
commit
e3e47b7cf7
@ -154,7 +154,7 @@ bool DebuggerImpl::CheckScriptParsed([[maybe_unused]] const std::string &fileNam
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerImpl::MethodEntry(JSHandle<Method> method)
|
void DebuggerImpl::MethodEntry(ScriptId scriptId, JSHandle<Method> method)
|
||||||
{
|
{
|
||||||
const JSPandaFile *jsPandaFile = method->GetJSPandaFile();
|
const JSPandaFile *jsPandaFile = method->GetJSPandaFile();
|
||||||
if (jsPandaFile == nullptr) {
|
if (jsPandaFile == nullptr) {
|
||||||
@ -173,7 +173,7 @@ void DebuggerImpl::MethodEntry(JSHandle<Method> method)
|
|||||||
// scriptParsed
|
// scriptParsed
|
||||||
const std::string &source = extractor->GetSourceCode(methodId);
|
const std::string &source = extractor->GetSourceCode(methodId);
|
||||||
const std::string &recordName = std::string(method->GetRecordNameStr());
|
const std::string &recordName = std::string(method->GetRecordNameStr());
|
||||||
SendableScriptParsed(g_scriptId++, fileName, url, source, recordName);
|
SendableScriptParsed(scriptId, fileName, url, source, recordName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
bool SendableScriptParsed(ScriptId scriptId, const std::string &fileName, const std::string &url,
|
bool SendableScriptParsed(ScriptId scriptId, const std::string &fileName, const std::string &url,
|
||||||
const std::string &source, const std::string &recordName);
|
const std::string &source, const std::string &recordName);
|
||||||
bool CheckScriptParsed(const std::string &fileName);
|
bool CheckScriptParsed(const std::string &fileName);
|
||||||
void MethodEntry(JSHandle<Method> method);
|
void MethodEntry(ScriptId scriptId, JSHandle<Method> method);
|
||||||
bool NotifySingleStep(const JSPtLocation &location);
|
bool NotifySingleStep(const JSPtLocation &location);
|
||||||
void NotifyPaused(std::optional<JSPtLocation> location, PauseReason reason);
|
void NotifyPaused(std::optional<JSPtLocation> location, PauseReason reason);
|
||||||
void GeneratePausedInfo(PauseReason reason,
|
void GeneratePausedInfo(PauseReason reason,
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
#include "agent/debugger_impl.h"
|
#include "agent/debugger_impl.h"
|
||||||
|
|
||||||
namespace panda::ecmascript::tooling {
|
namespace panda::ecmascript::tooling {
|
||||||
|
|
||||||
|
static std::atomic<uint32_t> g_scriptId {0};
|
||||||
|
|
||||||
void JSPtHooks::DebuggerStmt([[maybe_unused]] const JSPtLocation &location)
|
void JSPtHooks::DebuggerStmt([[maybe_unused]] const JSPtLocation &location)
|
||||||
{
|
{
|
||||||
LOG_DEBUGGER(VERBOSE) << "JSPHooks: Debugger Statement";
|
LOG_DEBUGGER(VERBOSE) << "JSPHooks: Debugger Statement";
|
||||||
@ -110,6 +113,6 @@ void JSPtHooks::MethodEntry(JSHandle<Method> method)
|
|||||||
|
|
||||||
[[maybe_unused]] LocalScope scope(debugger_->vm_);
|
[[maybe_unused]] LocalScope scope(debugger_->vm_);
|
||||||
|
|
||||||
debugger_->MethodEntry(method);
|
debugger_->MethodEntry(g_scriptId++, method);
|
||||||
}
|
}
|
||||||
} // namespace panda::ecmascript::tooling
|
} // namespace panda::ecmascript::tooling
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
namespace panda::ecmascript::tooling {
|
namespace panda::ecmascript::tooling {
|
||||||
class DebuggerImpl;
|
class DebuggerImpl;
|
||||||
|
|
||||||
static std::atomic<uint32_t> g_scriptId {0};
|
|
||||||
|
|
||||||
class JSPtHooks : public PtHooks {
|
class JSPtHooks : public PtHooks {
|
||||||
public:
|
public:
|
||||||
explicit JSPtHooks(DebuggerImpl *debugger) : debugger_(debugger) {}
|
explicit JSPtHooks(DebuggerImpl *debugger) : debugger_(debugger) {}
|
||||||
|
@ -121,17 +121,18 @@ void GetInputCommand([[maybe_unused]] void *arg)
|
|||||||
if (uv_is_active(reinterpret_cast<uv_handle_t*>(g_inputSignal))) {
|
if (uv_is_active(reinterpret_cast<uv_handle_t*>(g_inputSignal))) {
|
||||||
uint32_t len = inputStr.length();
|
uint32_t len = inputStr.length();
|
||||||
char* msg = (char*)malloc(len + 1);
|
char* msg = (char*)malloc(len + 1);
|
||||||
if ((msg != nullptr) && uv_is_active(reinterpret_cast<uv_handle_t*>(g_inputSignal))) {
|
if (msg == nullptr) {
|
||||||
if (strncpy_s(msg, len + 1, inputStr.c_str(), len) != 0) {
|
continue;
|
||||||
if (uv_is_active(reinterpret_cast<uv_handle_t*>(g_releaseHandle))) {
|
|
||||||
uv_async_send(g_releaseHandle);
|
|
||||||
}
|
|
||||||
free(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
g_inputSignal->data = std::move(msg);
|
|
||||||
uv_async_send(g_inputSignal);
|
|
||||||
}
|
}
|
||||||
|
if (strncpy_s(msg, len + 1, inputStr.c_str(), len) != 0) {
|
||||||
|
if (uv_is_active(reinterpret_cast<uv_handle_t*>(g_releaseHandle))) {
|
||||||
|
uv_async_send(g_releaseHandle);
|
||||||
|
}
|
||||||
|
free(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g_inputSignal->data = std::move(msg);
|
||||||
|
uv_async_send(g_inputSignal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,15 +102,16 @@ void TcpServer::SendCommand(std::string inputStr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char* msg = (char*)malloc(len + 1);
|
char* msg = (char*)malloc(len + 1);
|
||||||
if ((msg != nullptr) && uv_is_active(reinterpret_cast<uv_handle_t*>(g_inputSignal))) {
|
if (msg == nullptr) {
|
||||||
if (strncpy_s(msg, len + 1, inputStr.c_str(), len) != 0) {
|
return;
|
||||||
CloseServer();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_inputSignal->data = std::move(msg);
|
|
||||||
uv_async_send(g_inputSignal);
|
|
||||||
}
|
}
|
||||||
|
if (strncpy_s(msg, len + 1, inputStr.c_str(), len) != 0) {
|
||||||
|
free(msg);
|
||||||
|
CloseServer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_inputSignal->data = std::move(msg);
|
||||||
|
uv_async_send(g_inputSignal);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user