VirtualBox

Changeset 107166 in vbox


Ignore:
Timestamp:
Nov 27, 2024 1:25:02 PM (7 weeks ago)
Author:
vboxsync
Message:

Debugger/GDB: Add some basic arm64 support for the GDB remote stub, bugref:10393

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGCGdbRemoteStub.cpp

    r106061 r107166  
    10271027 * amd64 GDB register set.
    10281028 */
    1029 static const GDBREGDESC g_aGdbRegs64[] =
     1029static const GDBREGDESC g_aGdbRegsAmd64[] =
    10301030{
    10311031    DBGREG_DESC_INIT_INT64(     "rax",    DBGFREG_RAX),
     
    10771077 * i386 GDB register set.
    10781078 */
    1079 static const GDBREGDESC g_aGdbRegs32[] =
     1079static const GDBREGDESC g_aGdbRegsX86[] =
    10801080{
    10811081    DBGREG_DESC_INIT_INT32(     "eax",    DBGFREG_EAX),
     
    11151115};
    11161116
     1117
     1118/**
     1119 * arm64 GDB register set.
     1120 */
     1121static const GDBREGDESC g_aGdbRegsArm64[] =
     1122{
     1123    DBGREG_DESC_INIT_INT64(     "x0",     DBGFREG_ARMV8_GREG_X0),
     1124    DBGREG_DESC_INIT_INT64(     "x1",     DBGFREG_ARMV8_GREG_X1),
     1125    DBGREG_DESC_INIT_INT64(     "x2",     DBGFREG_ARMV8_GREG_X2),
     1126    DBGREG_DESC_INIT_INT64(     "x3",     DBGFREG_ARMV8_GREG_X3),
     1127    DBGREG_DESC_INIT_INT64(     "x4",     DBGFREG_ARMV8_GREG_X4),
     1128    DBGREG_DESC_INIT_INT64(     "x5",     DBGFREG_ARMV8_GREG_X5),
     1129    DBGREG_DESC_INIT_INT64(     "x6",     DBGFREG_ARMV8_GREG_X6),
     1130    DBGREG_DESC_INIT_INT64(     "x7",     DBGFREG_ARMV8_GREG_X7),
     1131    DBGREG_DESC_INIT_INT64(     "x8",     DBGFREG_ARMV8_GREG_X8),
     1132    DBGREG_DESC_INIT_INT64(     "x9",     DBGFREG_ARMV8_GREG_X9),
     1133    DBGREG_DESC_INIT_INT64(     "x10",    DBGFREG_ARMV8_GREG_X10),
     1134    DBGREG_DESC_INIT_INT64(     "x11",    DBGFREG_ARMV8_GREG_X11),
     1135    DBGREG_DESC_INIT_INT64(     "x12",    DBGFREG_ARMV8_GREG_X12),
     1136    DBGREG_DESC_INIT_INT64(     "x13",    DBGFREG_ARMV8_GREG_X13),
     1137    DBGREG_DESC_INIT_INT64(     "x14",    DBGFREG_ARMV8_GREG_X14),
     1138    DBGREG_DESC_INIT_INT64(     "x15",    DBGFREG_ARMV8_GREG_X15),
     1139    DBGREG_DESC_INIT_INT64(     "x16",    DBGFREG_ARMV8_GREG_X16),
     1140    DBGREG_DESC_INIT_INT64(     "x17",    DBGFREG_ARMV8_GREG_X17),
     1141    DBGREG_DESC_INIT_INT64(     "x18",    DBGFREG_ARMV8_GREG_X18),
     1142    DBGREG_DESC_INIT_INT64(     "x19",    DBGFREG_ARMV8_GREG_X19),
     1143    DBGREG_DESC_INIT_INT64(     "x20",    DBGFREG_ARMV8_GREG_X20),
     1144    DBGREG_DESC_INIT_INT64(     "x21",    DBGFREG_ARMV8_GREG_X21),
     1145    DBGREG_DESC_INIT_INT64(     "x22",    DBGFREG_ARMV8_GREG_X22),
     1146    DBGREG_DESC_INIT_INT64(     "x23",    DBGFREG_ARMV8_GREG_X23),
     1147    DBGREG_DESC_INIT_INT64(     "x24",    DBGFREG_ARMV8_GREG_X24),
     1148    DBGREG_DESC_INIT_INT64(     "x25",    DBGFREG_ARMV8_GREG_X25),
     1149    DBGREG_DESC_INIT_INT64(     "x26",    DBGFREG_ARMV8_GREG_X26),
     1150    DBGREG_DESC_INIT_INT64(     "x27",    DBGFREG_ARMV8_GREG_X27),
     1151    DBGREG_DESC_INIT_INT64(     "x28",    DBGFREG_ARMV8_GREG_X28),
     1152    DBGREG_DESC_INIT_INT64(     "x29",    DBGFREG_ARMV8_GREG_X29),
     1153    DBGREG_DESC_INIT_CODE_PTR64("x30",    DBGFREG_ARMV8_GREG_LR),
     1154
     1155    DBGREG_DESC_INIT_DATA_PTR64("sp",     DBGFREG_ARMV8_SP_EL1), /** @todo EL0 */
     1156    DBGREG_DESC_INIT_CODE_PTR64("pc",     DBGFREG_ARMV8_PC),
     1157
     1158    DBGREG_DESC_INIT_INT32(     "cpsr",   DBGFREG_ARMV8_PSTATE),
     1159};
     1160
     1161
    11171162#undef DBGREG_DESC_INIT_CODE_PTR64
    11181163#undef DBGREG_DESC_INIT_DATA_PTR64
     
    11331178static int dbgcGdbStubCtxTgtXmlDescCreate(PGDBSTUBCTX pThis)
    11341179{
    1135     static const char s_szXmlTgtHdr64[] =
     1180    static const char s_szXmlTgtHdrAmd64[] =
    11361181        "<?xml version=\"1.0\"?>\n"
    11371182        "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n"
     
    11391184        "    <architecture>i386:x86-64</architecture>\n"
    11401185        "    <feature name=\"org.gnu.gdb.i386.core\">\n";
    1141     static const char s_szXmlTgtHdr32[] =
     1186    static const char s_szXmlTgtHdrX86[] =
    11421187        "<?xml version=\"1.0\"?>\n"
    11431188        "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n"
     
    11451190        "    <architecture>i386</architecture>\n"
    11461191        "    <feature name=\"org.gnu.gdb.i386.core\">\n";
     1192    static const char s_szXmlTgtHdrArm64[] =
     1193        "<?xml version=\"1.0\"?>\n"
     1194        "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">\n"
     1195        "<target version=\"1.0\">\n"
     1196        "    <architecture>aarch64</architecture>\n"
     1197        "    <feature name=\"org.gnu.gdb.aarch64.core\">\n";
    11471198    static const char s_szXmlTgtFooter[] =
    11481199        "    </feature>\n"
     
    11581209        pThis->cbTgtXmlDesc = cbLeft;
    11591210
    1160         rc = RTStrCatP(&pachXmlCur, &cbLeft, pThis->paRegs == &g_aGdbRegs64[0] ? &s_szXmlTgtHdr64[0] : &s_szXmlTgtHdr32[0]);
     1211        const char *pszHdr = NULL;
     1212        if (pThis->paRegs == &g_aGdbRegsAmd64[0])
     1213            pszHdr = &s_szXmlTgtHdrAmd64[0];
     1214        else if (pThis->paRegs == &g_aGdbRegsX86[0])
     1215            pszHdr = &s_szXmlTgtHdrX86[0];
     1216        else if (pThis->paRegs == &g_aGdbRegsArm64[0])
     1217            pszHdr = &s_szXmlTgtHdrArm64[0];
     1218        else
     1219            return VERR_INVALID_STATE;
     1220
     1221        rc = RTStrCatP(&pachXmlCur, &cbLeft, pszHdr);
    11611222        if (RT_SUCCESS(rc))
    11621223        {
     
    17591820                uint32_t idxRegMax = 0;
    17601821                size_t cbRegs = 0;
    1761                 for (;;)
     1822                for (uint32_t i = 0; i < pThis->cRegs; i++)
    17621823                {
    17631824                    const GDBREGDESC *pReg = &pThis->paRegs[idxRegMax++];
    17641825                    cbRegs += pReg->cBits / 8;
    1765                     if (pReg->enmReg == DBGFREG_SS) /* Up to this seems to belong to the general register set. */
     1826                    if (pReg->enmReg == DBGFREG_SS) /* Up to this seems to belong to the general register set on x86/amd64. */
    17661827                        break;
    17671828                }
     
    25672628    {
    25682629        case CPUMMODE_PROTECTED:
    2569             pThis->paRegs = &g_aGdbRegs32[0];
    2570             pThis->cRegs  = RT_ELEMENTS(g_aGdbRegs32);
     2630            pThis->paRegs = &g_aGdbRegsX86[0];
     2631            pThis->cRegs  = RT_ELEMENTS(g_aGdbRegsX86);
    25712632            break;
    25722633        case CPUMMODE_LONG:
    2573             pThis->paRegs = &g_aGdbRegs64[0];
    2574             pThis->cRegs  = RT_ELEMENTS(g_aGdbRegs64);
     2634            pThis->paRegs = &g_aGdbRegsAmd64[0];
     2635            pThis->cRegs  = RT_ELEMENTS(g_aGdbRegsAmd64);
     2636            break;
     2637        case CPUMMODE_ARMV8_AARCH64:
     2638            pThis->paRegs = &g_aGdbRegsArm64[0];
     2639            pThis->cRegs  = RT_ELEMENTS(g_aGdbRegsArm64);
    25752640            break;
    25762641        case CPUMMODE_REAL:
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette