2020-08-08 01:47:37 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# Copyright (c) 2020 Intel Corporation
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2020-08-14 10:18:52 +08:00
|
|
|
from gdbstubs.arch.x86 import GdbStub_x86
|
|
|
|
from gdbstubs.arch.x86_64 import GdbStub_x86_64
|
2020-08-19 03:55:08 +08:00
|
|
|
from gdbstubs.arch.arm_cortex_m import GdbStub_ARM_CortexM
|
2020-08-14 10:18:52 +08:00
|
|
|
|
2020-08-08 01:47:37 +08:00
|
|
|
class TgtCode:
|
|
|
|
UNKNOWN = 0
|
2020-08-14 10:18:52 +08:00
|
|
|
X86 = 1
|
|
|
|
X86_64 = 2
|
2020-08-19 03:55:08 +08:00
|
|
|
ARM_CORTEX_M = 3
|
2020-08-08 01:47:37 +08:00
|
|
|
|
|
|
|
def get_gdbstub(logfile, elffile):
|
|
|
|
stub = None
|
|
|
|
|
|
|
|
tgt_code = logfile.log_hdr['tgt_code']
|
|
|
|
|
2020-08-14 10:18:52 +08:00
|
|
|
if tgt_code == TgtCode.X86:
|
|
|
|
stub = GdbStub_x86(logfile=logfile, elffile=elffile)
|
|
|
|
elif tgt_code == TgtCode.X86_64:
|
|
|
|
stub = GdbStub_x86_64(logfile=logfile, elffile=elffile)
|
2020-08-19 03:55:08 +08:00
|
|
|
elif tgt_code == TgtCode.ARM_CORTEX_M:
|
|
|
|
stub = GdbStub_ARM_CortexM(logfile=logfile, elffile=elffile)
|
2020-08-14 10:18:52 +08:00
|
|
|
|
2020-08-08 01:47:37 +08:00
|
|
|
return stub
|