1#!/usr/bin/env python3 2# 3# Copyright (c) 2020 Intel Corporation 4# 5# SPDX-License-Identifier: Apache-2.0 6 7from gdbstubs.arch.arm64 import GdbStub_ARM64 8from gdbstubs.arch.arm_cortex_m import GdbStub_ARM_CortexM 9from gdbstubs.arch.risc_v import GdbStub_RISC_V 10from gdbstubs.arch.x86 import GdbStub_x86 11from gdbstubs.arch.x86_64 import GdbStub_x86_64 12from gdbstubs.arch.xtensa import GdbStub_Xtensa 13 14 15class TgtCode: 16 UNKNOWN = 0 17 X86 = 1 18 X86_64 = 2 19 ARM_CORTEX_M = 3 20 RISC_V = 4 21 XTENSA = 5 22 ARM64 = 6 23 24 25def get_gdbstub(logfile, elffile): 26 stub = None 27 28 tgt_code = logfile.log_hdr['tgt_code'] 29 30 if tgt_code == TgtCode.X86: 31 stub = GdbStub_x86(logfile=logfile, elffile=elffile) 32 elif tgt_code == TgtCode.X86_64: 33 stub = GdbStub_x86_64(logfile=logfile, elffile=elffile) 34 elif tgt_code == TgtCode.ARM_CORTEX_M: 35 stub = GdbStub_ARM_CortexM(logfile=logfile, elffile=elffile) 36 elif tgt_code == TgtCode.RISC_V: 37 stub = GdbStub_RISC_V(logfile=logfile, elffile=elffile) 38 elif tgt_code == TgtCode.XTENSA: 39 stub = GdbStub_Xtensa(logfile=logfile, elffile=elffile) 40 elif tgt_code == TgtCode.ARM64: 41 stub = GdbStub_ARM64(logfile=logfile, elffile=elffile) 42 43 return stub 44