VirtualBox

Changeset 73460 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Aug 2, 2018 9:06:59 PM (6 years ago)
Author:
vboxsync
Message:

IPRT,DBGF,Diggers: Moved DBGFRETURNTYPE and the unwind state structure to IPRT (dbg.h) in prep for debug module interface and more. Added stack unwind assist callback for the OS diggers so they can identify special stack frames and supply more info via the sure-register-value array and frame flags. Identify and decode NT/AMD64 trap frames.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/dbgf.h

    r73444 r73460  
    12091209#ifdef IN_RING3 /* The stack API only works in ring-3. */
    12101210
    1211 /**
    1212  * Return type.
    1213  */
    1214 typedef enum DBGFRETRUNTYPE
    1215 {
    1216     /** The usual invalid 0 value. */
    1217     DBGFRETURNTYPE_INVALID = 0,
    1218     /** Near 16-bit return. */
    1219     DBGFRETURNTYPE_NEAR16,
    1220     /** Near 32-bit return. */
    1221     DBGFRETURNTYPE_NEAR32,
    1222     /** Near 64-bit return. */
    1223     DBGFRETURNTYPE_NEAR64,
    1224     /** Far 16:16 return. */
    1225     DBGFRETURNTYPE_FAR16,
    1226     /** Far 16:32 return. */
    1227     DBGFRETURNTYPE_FAR32,
    1228     /** Far 16:64 return. */
    1229     DBGFRETURNTYPE_FAR64,
    1230     /** 16-bit iret return (e.g. real or 286 protect mode). */
    1231     DBGFRETURNTYPE_IRET16,
    1232     /** 32-bit iret return. */
    1233     DBGFRETURNTYPE_IRET32,
    1234     /** 32-bit iret return. */
    1235     DBGFRETURNTYPE_IRET32_PRIV,
    1236     /** 32-bit iret return to V86 mode. */
    1237     DBGFRETURNTYPE_IRET32_V86,
    1238     /** @todo 64-bit iret return. */
    1239     DBGFRETURNTYPE_IRET64,
    1240     /** The end of the valid return types. */
    1241     DBGFRETURNTYPE_END,
    1242     /** The usual 32-bit blowup. */
    1243     DBGFRETURNTYPE_32BIT_HACK = 0x7fffffff
    1244 } DBGFRETURNTYPE;
    1245 
    1246 /**
    1247  * Figures the size of the return state on the stack.
    1248  *
    1249  * @returns number of bytes. 0 if invalid parameter.
    1250  * @param   enmRetType  The type of return.
    1251  */
    1252 DECLINLINE(unsigned) DBGFReturnTypeSize(DBGFRETURNTYPE enmRetType)
    1253 {
    1254     switch (enmRetType)
    1255     {
    1256         case DBGFRETURNTYPE_NEAR16:         return 2;
    1257         case DBGFRETURNTYPE_NEAR32:         return 4;
    1258         case DBGFRETURNTYPE_NEAR64:         return 8;
    1259         case DBGFRETURNTYPE_FAR16:          return 4;
    1260         case DBGFRETURNTYPE_FAR32:          return 4;
    1261         case DBGFRETURNTYPE_FAR64:          return 8;
    1262         case DBGFRETURNTYPE_IRET16:         return 6;
    1263         case DBGFRETURNTYPE_IRET32:         return 4*3;
    1264         case DBGFRETURNTYPE_IRET32_PRIV:    return 4*5;
    1265         case DBGFRETURNTYPE_IRET32_V86:     return 4*9;
    1266         case DBGFRETURNTYPE_IRET64:
    1267         default:
    1268             return 0;
    1269     }
    1270 }
    1271 
    1272 /**
    1273  * Check if near return.
    1274  *
    1275  * @returns true if near, false if far or iret.
    1276  * @param   enmRetType  The type of return.
    1277  */
    1278 DECLINLINE(bool) DBGFReturnTypeIsNear(DBGFRETURNTYPE enmRetType)
    1279 {
    1280     return enmRetType == DBGFRETURNTYPE_NEAR32
    1281         || enmRetType == DBGFRETURNTYPE_NEAR64
    1282         || enmRetType == DBGFRETURNTYPE_NEAR16;
    1283 }
    1284 
    1285 
    12861211/** Pointer to stack frame info. */
    12871212typedef struct DBGFSTACKFRAME *PDBGFSTACKFRAME;
     
    12951220    /** Frame number. */
    12961221    uint32_t        iFrame;
    1297     /** Frame flags. */
     1222    /** Frame flags (DBGFSTACKFRAME_FLAGS_XXX). */
    12981223    uint32_t        fFlags;
    12991224    /** The stack address of the frame.
     
    13111236    DBGFADDRESS     AddrFrame;
    13121237    /** The way this frame returns to the next one. */
    1313     DBGFRETURNTYPE enmReturnType;
     1238    RTDBGRETURNTYPE enmReturnType;
    13141239
    13151240    /** The way the next frame returns.
    13161241     * Only valid when DBGFSTACKFRAME_FLAGS_UNWIND_INFO_RET is set. */
    1317     DBGFRETURNTYPE enmReturnFrameReturnType;
     1242    RTDBGRETURNTYPE enmReturnFrameReturnType;
    13181243    /** The return frame address.
    13191244     * The off member is [e|r]bp and the Sel member is ss. */
     
    13581283} DBGFSTACKFRAME;
    13591284
    1360 /** @name DBGFSTACKFRAME Flags.
     1285/** @name DBGFSTACKFRAME_FLAGS_XXX - DBGFSTACKFRAME Flags.
    13611286 * @{ */
    13621287/** This is the last stack frame we can read.
     
    13751300/** Real mode or V86 frame. */
    13761301# define DBGFSTACKFRAME_FLAGS_REAL_V86          RT_BIT(7)
     1302/** Is a trap frame (NT term). */
     1303# define DBGFSTACKFRAME_FLAGS_TRAP_FRAME        RT_BIT(8)
     1304
    13771305/** Used Odd/even heuristics for far/near return. */
    1378 # define DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN     RT_BIT(8)
     1306# define DBGFSTACKFRAME_FLAGS_USED_ODD_EVEN     RT_BIT(29)
    13791307/** Set if we used unwind info to construct the frame. (Kind of internal.) */
    13801308# define DBGFSTACKFRAME_FLAGS_USED_UNWIND_INFO  RT_BIT(30)
     
    14041332VMMR3DECL(int)              DBGFR3StackWalkBeginEx(PUVM pUVM, VMCPUID idCpu, DBGFCODETYPE enmCodeType, PCDBGFADDRESS pAddrFrame,
    14051333                                                   PCDBGFADDRESS pAddrStack,PCDBGFADDRESS pAddrPC,
    1406                                                    DBGFRETURNTYPE enmReturnType, PCDBGFSTACKFRAME *ppFirstFrame);
     1334                                                   RTDBGRETURNTYPE enmReturnType, PCDBGFSTACKFRAME *ppFirstFrame);
    14071335VMMR3DECL(PCDBGFSTACKFRAME) DBGFR3StackWalkNext(PCDBGFSTACKFRAME pCurrent);
    14081336VMMR3DECL(void)             DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame);
     
    21242052
    21252053
     2054#ifdef IN_RING3
     2055
    21262056/**
    21272057 * Guest OS digger interface identifier.
     
    22562186     */
    22572187    DECLCALLBACKMEMBER(void *, pfnQueryInterface)(PUVM pUVM, void *pvData, DBGFOSINTERFACE enmIf);
     2188
     2189    /**
     2190     * Stack unwind assist callback.
     2191     *
     2192     * This is only called after pfnInit().
     2193     *
     2194     * @returns VBox status code (allocation error or something of  similar fatality).
     2195     * @param   pUVM            The user mode VM handle.
     2196     * @param   pvData          Pointer to the instance data.
     2197     * @param   idCpu           The CPU that's unwinding it's stack.
     2198     * @param   pFrame          The current frame. Okay to modify it a little.
     2199     * @param   pState          The unwind state.  Okay to modify it.
     2200     * @param   pInitialCtx     The initial register context.
     2201     * @param   hAs             The address space being used for the unwind.
     2202     * @param   puScratch       Scratch area (initialized to zero, no dtor).
     2203     */
     2204    DECLCALLBACKMEMBER(int, pfnStackUnwindAssist)(PUVM pUVM, void *pvData, VMCPUID idCpu, PDBGFSTACKFRAME pFrame,
     2205                                                  PRTDBGUNWINDSTATE pState, PCCPUMCTX pInitialCtx, RTDBGAS hAs,
     2206                                                  uint64_t *puScratch);
    22582207
    22592208    /** Trailing magic (DBGFOSREG_MAGIC). */
     
    23212270
    23222271
    2323 #ifdef IN_RING3
    23242272
    23252273/** @defgroup grp_dbgf_plug_in      The DBGF Plug-in Interface
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