common: Add x64_disassemble
This commit is contained in:
parent
731c7fa4d9
commit
4256d21481
3 changed files with 60 additions and 8 deletions
|
@ -62,6 +62,8 @@ add_library(dynarmic
|
|||
common/u128.cpp
|
||||
common/u128.h
|
||||
common/variant_util.h
|
||||
common/x64_disassemble.cpp
|
||||
common/x64_disassemble.h
|
||||
frontend/A32/types.cpp
|
||||
frontend/A32/types.h
|
||||
frontend/A64/types.cpp
|
||||
|
@ -99,12 +101,6 @@ add_library(dynarmic
|
|||
|
||||
if ("A32" IN_LIST DYNARMIC_FRONTENDS)
|
||||
target_sources(dynarmic PRIVATE
|
||||
interface/A32/a32.h
|
||||
interface/A32/arch_version.h
|
||||
interface/A32/config.h
|
||||
interface/A32/coprocessor.h
|
||||
interface/A32/coprocessor_util.h
|
||||
interface/A32/disassembler.h
|
||||
frontend/A32/decoder/arm.h
|
||||
frontend/A32/decoder/arm.inc
|
||||
frontend/A32/decoder/asimd.h
|
||||
|
@ -177,6 +173,12 @@ if ("A32" IN_LIST DYNARMIC_FRONTENDS)
|
|||
frontend/A32/translate/translate.h
|
||||
frontend/A32/translate/translate_arm.cpp
|
||||
frontend/A32/translate/translate_thumb.cpp
|
||||
interface/A32/a32.h
|
||||
interface/A32/arch_version.h
|
||||
interface/A32/config.h
|
||||
interface/A32/coprocessor.h
|
||||
interface/A32/coprocessor_util.h
|
||||
interface/A32/disassembler.h
|
||||
ir/opt/a32_constant_memory_reads_pass.cpp
|
||||
ir/opt/a32_get_set_elimination_pass.cpp
|
||||
)
|
||||
|
@ -286,9 +288,9 @@ if (ARCHITECTURE STREQUAL "x86_64")
|
|||
backend/x64/emit_x64_vector_saturation.cpp
|
||||
backend/x64/exception_handler.h
|
||||
backend/x64/exclusive_monitor.cpp
|
||||
backend/x64/host_feature.h
|
||||
backend/x64/hostloc.cpp
|
||||
backend/x64/hostloc.h
|
||||
backend/x64/host_feature.h
|
||||
backend/x64/jitstate_info.h
|
||||
backend/x64/oparg.h
|
||||
backend/x64/perf_map.cpp
|
||||
|
@ -363,12 +365,13 @@ create_target_directory_groups(dynarmic)
|
|||
target_include_directories(dynarmic PUBLIC ..)
|
||||
target_compile_options(dynarmic PRIVATE ${DYNARMIC_CXX_FLAGS})
|
||||
target_link_libraries(dynarmic
|
||||
PRIVATE
|
||||
PUBLIC
|
||||
boost
|
||||
fmt::fmt
|
||||
mp
|
||||
tsl::robin_map
|
||||
xbyak
|
||||
Zydis
|
||||
$<$<BOOL:DYNARMIC_USE_LLVM>:${llvm_libs}>
|
||||
)
|
||||
if (DYNARMIC_ENABLE_CPU_FEATURE_DETECTION)
|
||||
|
|
35
src/dynarmic/common/x64_disassemble.cpp
Normal file
35
src/dynarmic/common/x64_disassemble.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2021 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#include "dynarmic/common/x64_disassemble.h"
|
||||
|
||||
#include <Zydis/Zydis.h>
|
||||
#include <fmt/printf.h>
|
||||
|
||||
#include "dynarmic/common/common_types.h"
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
void DumpDisassembledX64(const void* ptr, size_t size) {
|
||||
ZydisDecoder decoder;
|
||||
ZydisDecoderInit(&decoder, ZYDIS_MACHINE_MODE_LONG_64, ZYDIS_ADDRESS_WIDTH_64);
|
||||
|
||||
ZydisFormatter formatter;
|
||||
ZydisFormatterInit(&formatter, ZYDIS_FORMATTER_STYLE_INTEL);
|
||||
|
||||
size_t offset = 0;
|
||||
ZydisDecodedInstruction instruction;
|
||||
while (ZYAN_SUCCESS(ZydisDecoderDecodeBuffer(&decoder, (const char*)ptr + offset, size - offset, &instruction))) {
|
||||
fmt::print("{:016x} ", (u64)ptr + offset);
|
||||
|
||||
char buffer[256];
|
||||
ZydisFormatterFormatInstruction(&formatter, &instruction, buffer, sizeof(buffer), (u64)ptr + offset);
|
||||
puts(buffer);
|
||||
|
||||
offset += instruction.length;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::Common
|
14
src/dynarmic/common/x64_disassemble.h
Normal file
14
src/dynarmic/common/x64_disassemble.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2021 MerryMage
|
||||
* SPDX-License-Identifier: 0BSD
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "dynarmic/common/common_types.h"
|
||||
|
||||
namespace Dynarmic::Common {
|
||||
|
||||
void DumpDisassembledX64(const void* ptr, size_t size);
|
||||
|
||||
} // namespace Dynarmic::Common
|
Loading…
Reference in a new issue