mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-10-07 13:54:17 +00:00
Add column number
Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/I8FXT1 test: build Signed-off-by: lphwork <liupenghui12@huawei.com>
This commit is contained in:
parent
dcd091277f
commit
f77c64a69e
1
BUILD.gn
1
BUILD.gn
@ -314,6 +314,7 @@ if (!ark_standalone_build) {
|
||||
"$ark_root/libpandafile/tests:host_unittest",
|
||||
"$ark_root/libziparchive/tests:host_unittest",
|
||||
"$ark_root/platforms/tests:host_unittest",
|
||||
"$ark_root/disassembler/tests:host_unittest",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -1788,4 +1788,15 @@ IdList Disassembler::GetInstructions(pandasm::Function *method, panda_file::File
|
||||
return unknown_external_methods;
|
||||
}
|
||||
|
||||
std::string Disassembler::GetColumnNumber()
|
||||
{
|
||||
std::string columnNumberStr = "";
|
||||
for (const auto method_info : prog_info_.methods_info) {
|
||||
for (const auto column_number : method_info.second.column_number_table) {
|
||||
columnNumberStr += std::to_string(column_number.column);
|
||||
}
|
||||
}
|
||||
return columnNumberStr;
|
||||
}
|
||||
|
||||
} // namespace panda::disasm
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
return prog_info_;
|
||||
}
|
||||
|
||||
std::string GetColumnNumber();
|
||||
|
||||
private:
|
||||
void GetLiteralArrays();
|
||||
void FillLiteralData(pandasm::LiteralArray *lit_array, const panda_file::LiteralDataAccessor::LiteralValue &value,
|
||||
|
79
disassembler/tests/BUILD.gn
Executable file
79
disassembler/tests/BUILD.gn
Executable file
@ -0,0 +1,79 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
|
||||
import("//arkcompiler/runtime_core/ark_config.gni")
|
||||
import("$ark_root/tests/test_helper.gni")
|
||||
|
||||
disasm_test_configs = [
|
||||
"$ark_root:ark_config",
|
||||
"$ark_root/libpandabase:arkbase_public_config",
|
||||
"$ark_root/libpandafile:arkfile_public_config",
|
||||
# "$ark_root/disassembler:arkdisassembler_public_config",
|
||||
sdk_libc_secshared_config,
|
||||
]
|
||||
|
||||
disasm_test_deps = [
|
||||
"$ark_root/libpandabase:libarkbase_static",
|
||||
"$ark_root/libpandafile:libarkfile_static",
|
||||
"$ark_root/disassembler:arkdisassembler",
|
||||
]
|
||||
|
||||
disasm_test_js_files = [ "disasm_column_numbers", ]
|
||||
|
||||
test_js_path = "//arkcompiler/runtime_core/disassembler/tests/js/"
|
||||
|
||||
foreach(file, disasm_test_js_files) {
|
||||
es2abc_gen_abc("gen_${file}_abc") {
|
||||
test_js = "${test_js_path}${file}.js"
|
||||
test_abc = "$target_out_dir/${file}.abc"
|
||||
|
||||
src_js = rebase_path(test_js)
|
||||
dst_file = rebase_path(test_abc)
|
||||
|
||||
in_puts = [ test_js ]
|
||||
out_puts = [ test_abc ]
|
||||
}
|
||||
}
|
||||
host_unittest_action("DisasmTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [ "columnnumber_test.cpp" ]
|
||||
|
||||
include_dirs = [
|
||||
"$ark_root/disassembler",
|
||||
"$ark_root/assembler",
|
||||
"$target_gen_dir",
|
||||
"$target_gen_dir/../",
|
||||
"$target_gen_dir/../../assembler",
|
||||
]
|
||||
|
||||
configs = disasm_test_configs
|
||||
|
||||
deps = disasm_test_deps
|
||||
test_abc_dir = rebase_path(target_out_dir)
|
||||
defines = [ "GRAPH_TEST_ABC_DIR=\"${test_abc_dir}/\"" ]
|
||||
foreach(file, disasm_test_js_files) {
|
||||
deps += [ ":gen_${file}_abc" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("host_unittest") {
|
||||
testonly = true
|
||||
print("-----------------------------------------test------------------------------------------------------")
|
||||
deps = [ ":DisasmTestAction" ]
|
||||
print("target_gen_dir: $target_gen_dir")
|
||||
print("target_out_dir: $target_out_dir")
|
||||
print("----------------------------------------disassember-test------------------------------------------------------")
|
||||
}
|
||||
|
32
disassembler/tests/columnnumber_test.cpp
Executable file
32
disassembler/tests/columnnumber_test.cpp
Executable file
@ -0,0 +1,32 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <string>
|
||||
#include "../disassembler.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
namespace panda::disasm{
|
||||
class DisasmTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void) {};
|
||||
static void TearDownTestCase(void) {};
|
||||
void SetUp() {};
|
||||
void TearDown() {};
|
||||
};
|
||||
|
||||
HWTEST_F(DisasmTest, disasm_column_numbers, TestSize.Level1)
|
||||
{
|
||||
std::cout << "执行到了获取abc文件之前了" << std::endl;
|
||||
const std::string file_name = GRAPH_TEST_ABC_DIR "disasm_column_numbers.abc";
|
||||
std::cout << "abc filename:" << file_name << std::endl;
|
||||
panda::disasm::Disassembler disasm {};
|
||||
std::cout << "执行到初始化之后了" << std::endl;
|
||||
disasm.Disassemble(file_name, false, false);
|
||||
std::cout << "执行到Dissaemble" << std::endl;
|
||||
disasm.CollectInfo();
|
||||
std::cout << "执行到CollectInfo" << std::endl;
|
||||
std::string number_str = "848484128128412161281281216128114158208158404086860";
|
||||
std::cout << "number_str: " << number_str << std::endl;
|
||||
std::string column_number_str = disasm.GetColumnNumber();
|
||||
std::cout << "column_number_str: " << column_number_str << std::endl;
|
||||
EXPECT_TRUE(number_str == column_number_str);
|
||||
}
|
||||
}
|
32
disassembler/tests/js/disasm_column_numbers.js
Executable file
32
disassembler/tests/js/disasm_column_numbers.js
Executable file
@ -0,0 +1,32 @@
|
||||
import {aaa} from './base.js'
|
||||
|
||||
function A() {
|
||||
a = 2;
|
||||
b = 2;
|
||||
c = 2;
|
||||
}
|
||||
|
||||
function B() {
|
||||
let a = 0;
|
||||
let b = 0;
|
||||
}
|
||||
|
||||
a = 0;
|
||||
b = 0;
|
||||
|
||||
function C() {
|
||||
let m = a + b;
|
||||
}
|
||||
|
||||
function D() {
|
||||
let d = a + b;
|
||||
let e = 3;
|
||||
let m = d + e;
|
||||
return m;
|
||||
}
|
||||
|
||||
class E {
|
||||
constructor(name) {
|
||||
this.name = name
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user