VirtualBox

Changeset 61671 in vbox for trunk


Ignore:
Timestamp:
Jun 13, 2016 8:51:05 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
108025
Message:

VMM/DBGF: Start on a simple type system to pretty print structs in the guest later on, work in progress

Location:
trunk
Files:
1 added
3 edited

Legend:

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

    r61634 r61671  
    22402240
    22412241/** @} */
     2242
     2243/** @defgroup grp_dbgf_types        The DBGF type system Interface.
     2244 * @{
     2245 */
     2246
     2247/** A few forward declarations. */
     2248/** Pointer to a type registration structure. */
     2249typedef struct DBGFTYPEREG *PDBGFTYPEREG;
     2250/** Pointer to a const type registration structure. */
     2251typedef const struct DBGFTYPEREG *PCDBGFTYPEREG;
     2252/** Pointer to a typed buffer. */
     2253typedef struct DBGFTYPEVAL *PDBGFTYPEVAL;
     2254
     2255/**
     2256 * DBGF built-in types.
     2257 */
     2258typedef enum DBGFTYPEBUILTIN
     2259{
     2260    /** The usual invalid first value. */
     2261    DBGFTYPEBUILTIN_INVALID,
     2262    /** Unsigned 8bit integer. */
     2263    DBGFTYPEBUILTIN_UINT8,
     2264    /** Signed 8bit integer. */
     2265    DBGFTYPEBUILTIN_INT8,
     2266    /** Unsigned 16bit integer. */
     2267    DBGFTYPEBUILTIN_UINT16,
     2268    /** Signed 16bit integer. */
     2269    DBGFTYPEBUILTIN_INT16,
     2270    /** Unsigned 32bit integer. */
     2271    DBGFTYPEBUILTIN_UINT32,
     2272    /** Signed 32bit integer. */
     2273    DBGFTYPEBUILTIN_INT32,
     2274    /** Unsigned 64bit integer. */
     2275    DBGFTYPEBUILTIN_UINT64,
     2276    /** Signed 64bit integer. */
     2277    DBGFTYPEBUILTIN_INT64,
     2278    /** 32bit Guest pointer */
     2279    DBGFTYPEBUILTIN_PTR32,
     2280    /** 64bit Guest pointer */
     2281    DBGFTYPEBUILTIN_PTR64,
     2282    /** Guest pointer - size depends on the guest bitness */
     2283    DBGFTYPEBUILTIN_PTR,
     2284    /** Type indicating a size, like size_t this can have different sizes
     2285     * on 32bit and 64bit systems */
     2286    DBGFTYPEBUILTIN_SIZE,
     2287    /** 32bit float. */
     2288    DBGFTYPEBUILTIN_FLOAT32,
     2289    /** 64bit float (also known as double). */
     2290    DBGFTYPEBUILTIN_FLOAT64,
     2291    /** Compund types like structs and unions. */
     2292    DBGFTYPEBUILTIN_COMPOUND,
     2293    /** The usual 32-bit hack. */
     2294    DBGFTYPEBUILTIN_32BIT_HACK = 0x7fffffff
     2295} DBGFTYPEBUILTIN;
     2296/** Pointer to a built-in type. */
     2297typedef DBGFTYPEBUILTIN *PDBGFTYPEBUILTIN;
     2298/** Pointer to a const built-in type. */
     2299typedef const DBGFTYPEBUILTIN *PCDBGFTYPEBUILTIN;
     2300
     2301/**
     2302 * DBGF type value buffer.
     2303 */
     2304typedef union DBGFTYPEVALBUF
     2305{
     2306    uint8_t          u8;
     2307    int8_t           i8;
     2308    uint16_t         u16;
     2309    int16_t          i16;
     2310    uint32_t         u32;
     2311    int32_t          i32;
     2312    uint64_t         u64;
     2313    int64_t          i64;
     2314    float            f32;
     2315    double           f64;
     2316    RTGCPTR          GCPtr;
     2317    /** For embedded structs. */
     2318    PDBGFTYPEVAL     pVal;
     2319} DBGFTYPEVALBUF;
     2320/** Pointer to a value. */
     2321typedef DBGFTYPEVALBUF *PDBGFTYPEVALBUF;
     2322
     2323/**
     2324 * DBGF type value entry.
     2325 */
     2326typedef struct DBGFTYPEVALENTRY
     2327{
     2328    /** DBGF built-in type. */
     2329    DBGFTYPEBUILTIN      enmType;
     2330    /** Number of entries, for arrays this can be > 1. */
     2331    uint32_t             cEntries;
     2332    /** Value buffer, depends on whether this is an array. */
     2333    union
     2334    {
     2335        /** Single value. */
     2336        DBGFTYPEVALBUF   Val;
     2337        /** Pointer to the array of values. */
     2338        PDBGFTYPEVALBUF  pVal;
     2339    } Buf;
     2340} DBGFTYPEVALENTRY;
     2341/** Pointer to a type value entry. */
     2342typedef DBGFTYPEVALENTRY *PDBGFTYPEVALENTRY;
     2343/** Pointer to a const type value entry. */
     2344typedef const DBGFTYPEVALENTRY *PCDBGFTYPEVALENTRY;
     2345
     2346/**
     2347 * DBGF typed value.
     2348 */
     2349typedef struct DBGFTYPEVAL
     2350{
     2351    /** Pointer to the registration structure for this type. */
     2352    PCDBGFTYPEREG        pTypeReg;
     2353    /** Number of value entries. */
     2354    uint32_t             cEntries;
     2355    /** Variable sized array of value entries. */
     2356    DBGFTYPEVALENTRY     aEntries[1];
     2357} DBGFTYPEVAL;
     2358
     2359/**
     2360 * DBGF type variant.
     2361 */
     2362typedef enum DBGFTYPEVARIANT
     2363{
     2364    /** The usual invalid first value. */
     2365    DBGFTYPEVARIANT_INVALID,
     2366    /** A struct. */
     2367    DBGFTYPEVARIANT_STRUCT,
     2368    /** Union. */
     2369    DBGFTYPEVARIANT_UNION,
     2370    /** Alias for an existing type. */
     2371    DBGFTYPEVARIANT_ALIAS,
     2372    /** The usual 32-bit hack. */
     2373    DBGFTYPEVARIANT_32BIT_HACK = 0x7fffffff
     2374} DBGFTYPEVARIANT;
     2375
     2376/** @name DBGFTYPEREGMEMBER Flags.
     2377 * @{ */
     2378/** The member is an array with a fixed size. */
     2379# define DBGFTYPEREGMEMBER_F_ARRAY   RT_BIT_32(0)
     2380/** The member denotes a pointer. */
     2381# define DBGFTYPEREGMEMBER_F_POINTER RT_BIT_32(1)
     2382/** @} */
     2383
     2384/**
     2385 * DBGF type member.
     2386 */
     2387typedef struct DBGFTYPEREGMEMBER
     2388{
     2389    /** Name of the member. */
     2390    const char          *pszName;
     2391    /** Flags for this member, see DBGFTYPEREGMEMBER_F_XXX. */
     2392    uint32_t             fFlags;
     2393    /** Type identifier. */
     2394    const char          *pszType;
     2395    /** The number of elements in the array, only valid for arrays. */
     2396    uint32_t             cElements;
     2397} DBGFTYPEREGMEMBER;
     2398/** Pointer to a member. */
     2399typedef DBGFTYPEREGMEMBER *PDBGFTYPEREGMEMBER;
     2400/** Pointer to a const member. */
     2401typedef const DBGFTYPEREGMEMBER *PCDBGFTYPEREGMEMBER;
     2402
     2403/** @name DBGFTYPEREG Flags.
     2404 * @{ */
     2405/** The type is a packed structure. */
     2406# define DBGFTYPEREG_F_PACKED        RT_BIT_32(0)
     2407/** @} */
     2408
     2409/**
     2410 * New type registration structure.
     2411 */
     2412typedef struct DBGFTYPEREG
     2413{
     2414    /** Name of the type. */
     2415    const char          *pszType;
     2416    /** The type variant. */
     2417    DBGFTYPEVARIANT      enmVariant;
     2418    /** Some registration flags, see DBGFTYPEREG_F_XXX. */
     2419    uint32_t             fFlags;
     2420    /** Number of members this type has, only valid for structs or unions. */
     2421    uint32_t             cMembers;
     2422    /** Pointer to the member fields, only valid for structs or unions. */
     2423    PCDBGFTYPEREGMEMBER  paMembers;
     2424    /** Name of the aliased type for aliases. */
     2425    const char          *pszAliasedType;
     2426} DBGFTYPEREG;
     2427
     2428VMMR3DECL(int) DBGFR3TypeRegister(  PUVM pUVM, uint32_t cTypes, PCDBGFTYPEREG paTypes);
     2429VMMR3DECL(int) DBGFR3TypeDeregister(PUVM pUVM, const char *pszType);
     2430VMMR3DECL(int) DBGFR3TypeQueryReg(  PUVM pUVM, const char *pszType, PCDBGFTYPEREG *ppTypeReg);
     2431
     2432VMMR3DECL(int) DBGFR3TypeQuerySize( PUVM pUVM, const char *pszType, size_t *pcbType);
     2433VMMR3DECL(int) DBGFR3TypeSetSize(   PUVM pUVM, const char *pszType, size_t cbType);
     2434VMMR3DECL(int) DBGFR3TypeQueryValByType(PUVM pUVM, PCDBGFADDRESS pAddress, const char *pszType,
     2435                                        PDBGFTYPEVAL *ppVal);
     2436VMMR3DECL(void) DBGFR3TypeValFree(PDBGFTYPEVAL pVal);
     2437
     2438/** @} */
    22422439#endif /* IN_RING3 */
    22432440
    2244 
    22452441/** @} */
    22462442
  • trunk/src/VBox/VMM/Makefile.kmk

    r61348 r61671  
    164164        VMMR3/DBGFStack.cpp \
    165165        VMMR3/DBGFR3Trace.cpp \
     166        VMMR3/DBGFR3Type.cpp \
    166167        VMMR3/EM.cpp \
    167168        VMMR3/EMR3Dbg.cpp \
  • trunk/src/VBox/VMM/include/DBGFInternal.h

    r58910 r61671  
    414414    R3PTRTYPE(PDBGFINFO)        pInfoFirst;
    415415
     416    /** The type database lock. */
     417    RTSEMRW                     hTypeDbLock;
     418    /** String space for looking up types.  (Protected by hTypeDbLock.) */
     419    R3PTRTYPE(RTSTRSPACE)       TypeSpace;
     420    /** For early initialization by . */
     421    bool volatile               fTypeDbInitialized;
     422    /** Alignment padding. */
     423    bool                        afAlignment3[3];
     424
    416425} DBGFUSERPERVM;
    417426typedef DBGFUSERPERVM *PDBGFUSERPERVM;
     
    443452void dbgfR3TraceRelocate(PVM pVM);
    444453void dbgfR3TraceTerm(PVM pVM);
     454DECLHIDDEN(int)  dbgfR3TypeInit(PUVM pUVM);
     455DECLHIDDEN(void) dbgfR3TypeTerm(PUVM pUVM);
    445456int  dbgfR3PlugInInit(PUVM pUVM);
    446457void dbgfR3PlugInTerm(PUVM pUVM);
Note: See TracChangeset for help on using the changeset viewer.

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