Descriptor: modify stream and add switch of enable_dump_in_faultlog

details:
1. call EndOfStream after WriteChunk
2. add switch of enable_dump_in_faultlog
issue: https://gitee.com/openharmony/ark_js_runtime/issues/I58KLM

Signed-off-by: wengchangcheng <wengchangcheng@huawei.com>
Change-Id: I1c9b26873eae47f8e9e5788cd7a477f32738efc9
This commit is contained in:
wengchangcheng 2022-05-21 14:28:29 +08:00
parent bdd9e6a94b
commit 4aa58c6ba0
8 changed files with 24 additions and 42 deletions

View File

@ -544,8 +544,9 @@ source_set("libark_jsruntime_set") {
public_configs += [ ":ark_jsruntime_windows_config" ]
}
cflags_cc = []
if (is_standard_system) {
cflags_cc = [ "-fvisibility=hidden" ]
cflags_cc += [ "-fvisibility=hidden" ]
}
deps = [
@ -559,19 +560,18 @@ source_set("libark_jsruntime_set") {
deps += [ ":copy_asan_runtime" ]
}
defines = []
include_dirs = []
if (is_ohos && is_standard_system) {
defines = []
include_dirs = []
if (enable_bytrace) {
defines += [ "ENABLE_BYTRACE" ]
include_dirs += [ "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter" ]
cflags_cc += [ "-Wno-gnu-zero-variadic-macro-arguments" ]
}
if (enable_dump_in_faultlog) {
defines += [ "ENABLE_DUMP_IN_FAULTLOG" ]
include_dirs += [ "//base/hiviewdfx/faultloggerd/interfaces/innerkits/faultloggerd_client" ]
}
defines += [ "ENABLE_DUMP_IN_FAULTLOG" ]
include_dirs += [
"//base/hiviewdfx/faultloggerd/interfaces/innerkits/faultloggerd_client",
]
cflags_cc += [ "-Wno-gnu-zero-variadic-macro-arguments" ]
}
}
@ -623,11 +623,12 @@ if (!defined(ark_independent_build)) {
":libark_jsruntime_set",
]
defines = []
if (is_ohos && is_standard_system) {
external_deps = [ "faultloggerd:libfaultloggerd" ]
external_deps = []
if (enable_dump_in_faultlog) {
external_deps += [ "faultloggerd:libfaultloggerd" ]
}
if (enable_bytrace) {
defines += [ "ENABLE_BYTRACE" ]
external_deps += [ "hitrace_native:hitrace_meter" ]
}
}
@ -647,12 +648,6 @@ if (!defined(ark_independent_build)) {
ohos_shared_library("libark_jsruntime_test") {
deps = [ ":libark_jsruntime_test_set" ]
defines = []
if (is_ohos && is_standard_system && enable_bytrace) {
defines += [ "ENABLE_BYTRACE" ]
external_deps = [ "hitrace_native:hitrace_meter" ]
}
install_enable = false
if (!is_mingw && !is_mac) {
output_extension = "so"

View File

@ -213,5 +213,6 @@ void HeapSnapshotJSONSerializer::WriteChunk()
LOG_ECMA(ERROR) << "WriteChunk failed";
}
}
stream_->EndOfStream();
}
} // namespace panda::ecmascript

View File

@ -50,7 +50,6 @@ public:
JSHandle<JSTaggedValue> newTarget, size_t numArgs);
static inline JSTaggedValue GeneratorReEnterInterpreter(JSThread *thread, JSHandle<GeneratorContext> context);
static inline void RunInternal(JSThread *thread, ConstantPool *constpool, const uint8_t *pc, JSTaggedType *sp);
static inline uint8_t ReadU8(const uint8_t *pc, uint32_t offset);
static inline void InitStackFrame(JSThread *thread);
static inline uint32_t FindCatchBlock(JSMethod *caller, uint32_t pc);
static inline size_t GetJumpSizeAfterCall(const uint8_t *prevPc);

View File

@ -66,7 +66,6 @@ void DFXJSNApi::DumpHeapSnapshot([[maybe_unused]] EcmaVM *vm, [[maybe_unused]] i
}
FileDescriptorStream stream(fd);
DumpHeapSnapshot(vm, dumpFormat, &stream, nullptr, isVmMode, isPrivate);
close(fd);
#endif
}

View File

@ -16,7 +16,7 @@
#ifndef ECMASCRIPT_SHARED_MEMORY_MANAGER_MANAGER_H
#define ECMASCRIPT_SHARED_MEMORY_MANAGER_MANAGER_H
#include "ecmascript/tooling/js_pt_extractor.h"
#include "ecmascript/mem/c_containers.h"
#include "libpandabase/utils/logger.h"
#include "os/mutex.h"

View File

@ -27,18 +27,11 @@ FileStream::FileStream(const std::string &fileName)
Initialize(fileName);
}
FileStream::~FileStream()
{
EndOfStream();
}
void FileStream::EndOfStream()
{
if (fileStream_.fail()) {
return;
if (Good()) {
fileStream_.close();
}
fileStream_.close();
}
bool FileStream::Good()
@ -93,14 +86,11 @@ bool FileStream::WriteChunk(char* data, int size)
return true;
}
FileDescriptorStream::~FileDescriptorStream()
{
EndOfStream();
}
void FileDescriptorStream::EndOfStream()
{
LOG_ECMA(INFO) << "FileDescriptorStream" << fd_;
if (Good()) {
close(fd_);
}
}
bool FileDescriptorStream::Good()

View File

@ -24,7 +24,7 @@ namespace panda::ecmascript {
class FileStream : public Stream {
public:
FileStream(const std::string &fileName);
~FileStream() override;
~FileStream() override = default;
void EndOfStream() override;
@ -48,11 +48,8 @@ private:
class FileDescriptorStream : public Stream {
public:
explicit FileDescriptorStream(int32_t fd): fd_(fd)
{
}
~FileDescriptorStream() override;
explicit FileDescriptorStream(int32_t fd): fd_(fd) {}
~FileDescriptorStream() override = default;
void EndOfStream() override;

View File

@ -23,6 +23,7 @@ if (!defined(ark_independent_build)) {
compile_llvm_online = false
run_with_asan = false
enable_bytrace = true
enable_dump_in_faultlog = true
asan_lib_path = "/usr/lib/llvm-10/lib/clang/10.0.0/lib/linux"
# For OpenHarmony build, always link with the static lib: