Changeset 31966 in vbox for trunk/src/VBox/Debugger
- Timestamp:
- Aug 25, 2010 4:15:25 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 65199
- Location:
- trunk/src/VBox/Debugger
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCCmdHlp.cpp
r31530 r31966 792 792 793 793 /** 794 * @interface_method_impl{DBGCCMDHLP,pfnVarGetRange} 795 */ 796 static DECLCALLBACK(int) dbgcHlpVarGetRange(PDBGCCMDHLP pCmdHlp, PCDBGCVAR pVar, uint64_t cbElement, uint64_t cbDefault, 797 uint64_t *pcbRange) 798 { 799 /** @todo implement this properly, strings/symbols are not resolved now. */ 800 switch (pVar->enmRangeType) 801 { 802 default: 803 case DBGCVAR_RANGE_NONE: 804 *pcbRange = cbDefault; 805 break; 806 case DBGCVAR_RANGE_BYTES: 807 *pcbRange = pVar->u64Range; 808 break; 809 case DBGCVAR_RANGE_ELEMENTS: 810 *pcbRange = pVar->u64Range * cbElement; 811 break; 812 } 813 return VINF_SUCCESS; 814 } 815 816 817 /** 818 * Info helper callback wrapper - print formatted string. 819 * 820 * @param pHlp Pointer to this structure. 821 * @param pszFormat The format string. 822 * @param ... Arguments. 823 */ 824 static DECLCALLBACK(void) dbgcHlpGetDbgfOutputHlp_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...) 825 { 826 PDBGC pDbgc = RT_FROM_MEMBER(pHlp, DBGC, DbgfOutputHlp); 827 va_list va; 828 va_start(va, pszFormat); 829 pDbgc->CmdHlp.pfnPrintfV(&pDbgc->CmdHlp, NULL, pszFormat, va); 830 va_end(va); 831 } 832 833 834 /** 835 * Info helper callback wrapper - print formatted string. 836 * 837 * @param pHlp Pointer to this structure. 838 * @param pszFormat The format string. 839 * @param args Argument list. 840 */ 841 static DECLCALLBACK(void) dbgcHlpGetDbgfOutputHlp_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args) 842 { 843 PDBGC pDbgc = RT_FROM_MEMBER(pHlp, DBGC, DbgfOutputHlp); 844 pDbgc->CmdHlp.pfnPrintfV(&pDbgc->CmdHlp, NULL, pszFormat, args); 845 } 846 847 848 /** 849 * @interface_method_impl{DBGCCMDHLP,pfnGetDbgfOutputHlp} 850 */ 851 static DECLCALLBACK(PCDBGFINFOHLP) dbgcHlpGetDbgfOutputHlp(PDBGCCMDHLP pCmdHlp) 852 { 853 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 854 855 /* Lazy init */ 856 if (!pDbgc->DbgfOutputHlp.pfnPrintf) 857 { 858 pDbgc->DbgfOutputHlp.pfnPrintf = dbgcHlpGetDbgfOutputHlp_Printf; 859 pDbgc->DbgfOutputHlp.pfnPrintfV = dbgcHlpGetDbgfOutputHlp_PrintfV; 860 } 861 862 return &pDbgc->DbgfOutputHlp; 863 } 864 865 866 /** 794 867 * Initializes the Command Helpers for a DBGC instance. 795 868 * … … 798 871 void dbgcInitCmdHlp(PDBGC pDbgc) 799 872 { 800 pDbgc->CmdHlp.pfnWrite = dbgcHlpWrite; 801 pDbgc->CmdHlp.pfnPrintfV = dbgcHlpPrintfV; 802 pDbgc->CmdHlp.pfnPrintf = dbgcHlpPrintf; 803 pDbgc->CmdHlp.pfnVBoxErrorV = dbgcHlpVBoxErrorV; 804 pDbgc->CmdHlp.pfnVBoxError = dbgcHlpVBoxError; 805 pDbgc->CmdHlp.pfnMemRead = dbgcHlpMemRead; 806 pDbgc->CmdHlp.pfnMemWrite = dbgcHlpMemWrite; 807 pDbgc->CmdHlp.pfnEvalV = dbgcHlpEvalV; 808 pDbgc->CmdHlp.pfnExec = dbgcHlpExec; 809 pDbgc->CmdHlp.pfnFailV = dbgcHlpFailV; 810 pDbgc->CmdHlp.pfnVarToDbgfAddr = dbgcHlpVarToDbgfAddr; 811 pDbgc->CmdHlp.pfnVarToBool = dbgcHlpVarToBool; 812 } 813 873 pDbgc->CmdHlp.pfnWrite = dbgcHlpWrite; 874 pDbgc->CmdHlp.pfnPrintfV = dbgcHlpPrintfV; 875 pDbgc->CmdHlp.pfnPrintf = dbgcHlpPrintf; 876 pDbgc->CmdHlp.pfnVBoxErrorV = dbgcHlpVBoxErrorV; 877 pDbgc->CmdHlp.pfnVBoxError = dbgcHlpVBoxError; 878 pDbgc->CmdHlp.pfnMemRead = dbgcHlpMemRead; 879 pDbgc->CmdHlp.pfnMemWrite = dbgcHlpMemWrite; 880 pDbgc->CmdHlp.pfnEvalV = dbgcHlpEvalV; 881 pDbgc->CmdHlp.pfnExec = dbgcHlpExec; 882 pDbgc->CmdHlp.pfnFailV = dbgcHlpFailV; 883 pDbgc->CmdHlp.pfnVarToDbgfAddr = dbgcHlpVarToDbgfAddr; 884 pDbgc->CmdHlp.pfnVarToBool = dbgcHlpVarToBool; 885 pDbgc->CmdHlp.pfnVarGetRange = dbgcHlpVarGetRange; 886 pDbgc->CmdHlp.pfnGetDbgfOutputHlp = dbgcHlpGetDbgfOutputHlp; 887 } 888 -
trunk/src/VBox/Debugger/DBGCCommands.cpp
r31530 r31966 874 874 875 875 /** 876 * Print formatted string.877 *878 * @param pHlp Pointer to this structure.879 * @param pszFormat The format string.880 * @param ... Arguments.881 */882 static DECLCALLBACK(void) dbgcCmdInfo_Printf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...)883 {884 PDBGCCMDHLP pCmdHlp = *(PDBGCCMDHLP *)(pHlp + 1);885 va_list args;886 va_start(args, pszFormat);887 pCmdHlp->pfnPrintfV(pCmdHlp, NULL, pszFormat, args);888 va_end(args);889 }890 891 892 /**893 * Print formatted string.894 *895 * @param pHlp Pointer to this structure.896 * @param pszFormat The format string.897 * @param args Argument list.898 */899 static DECLCALLBACK(void) dbgcCmdInfo_PrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)900 {901 PDBGCCMDHLP pCmdHlp = *(PDBGCCMDHLP *)(pHlp + 1);902 pCmdHlp->pfnPrintfV(pCmdHlp, NULL, pszFormat, args);903 }904 905 906 /**907 876 * The 'info' command. 908 877 * … … 932 901 * Dump it. 933 902 */ 934 struct 935 { 936 DBGFINFOHLP Hlp; 937 DBGCCMDHLP *pCmdHlp; /* XXX gcc warns when using PDBGCCMDHLP here */ 938 } Hlp = { { dbgcCmdInfo_Printf, dbgcCmdInfo_PrintfV }, pCmdHlp }; 939 int rc = VMR3ReqCallWait(pVM, pDbgc->idCpu, 940 (PFNRT)DBGFR3Info, 4, pVM, paArgs[0].u.pszString, cArgs == 2 ? paArgs[1].u.pszString : NULL, &Hlp.Hlp); 903 int rc = VMR3ReqCallWait(pVM, pDbgc->idCpu, (PFNRT)DBGFR3Info, 4, 904 pVM, paArgs[0].u.pszString, cArgs == 2 ? paArgs[1].u.pszString : NULL, 905 DBGCCmdHlpGetDbgfOutputHlp(pCmdHlp)); 941 906 if (RT_FAILURE(rc)) 942 907 return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3Info()\n"); -
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r31769 r31966 58 58 static DECLCALLBACK(int) dbgcCmdDumpPageDir(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 59 59 static DECLCALLBACK(int) dbgcCmdDumpPageDirBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 60 static DECLCALLBACK(int) dbgcCmdDumpPageHierarchy(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 60 61 static DECLCALLBACK(int) dbgcCmdDumpPageTable(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 61 62 static DECLCALLBACK(int) dbgcCmdDumpPageTableBoth(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); … … 164 165 /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ 165 166 { 0, 1, DBGCVAR_CAT_POINTER, 0, "address", "Address of the page directory entry to start dumping from." }, 167 }; 168 169 170 /** 'dph*' arguments. */ 171 static const DBGCVARDESC g_aArgDumpPH[] = 172 { 173 /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ 174 { 0, 1, DBGCVAR_CAT_GC_POINTER, 0, "address", "Where in the address space to start dumping and for how long (range). The default address/range will be used if omitted." }, 175 { 0, 1, DBGCVAR_CAT_NUMBER, DBGCVD_FLAGS_DEP_PREV, "cr3", "The CR3 value to use. The current CR3 of the context will be used if omitted." }, 176 { 0, 1, DBGCVAR_CAT_STRING, DBGCVD_FLAGS_DEP_PREV, "mode", "The paging mode: legacy, pse, pae, long, ept. Append '-np' for nested paging and '-nx' for no-execute. The current mode will be used if omitted." }, 166 177 }; 167 178 … … 314 325 { "dpdg", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), NULL, 0, dbgcCmdDumpPageDir, "[addr] [index]", "Dumps page directory entries of the guest." }, 315 326 { "dpdh", 0, 1, &g_aArgDumpPD[0], RT_ELEMENTS(g_aArgDumpPD), NULL, 0, dbgcCmdDumpPageDir, "[addr] [index]", "Dumps page directory entries of the hypervisor. " }, 327 { "dph", 0, 3, &g_aArgDumpPH[0], RT_ELEMENTS(g_aArgDumpPH), NULL, 0, dbgcCmdDumpPageHierarchy, "[addr [cr3 [mode]]", "Dumps the paging hierarchy at for specfied address range. Default context." }, 328 { "dphg", 0, 3, &g_aArgDumpPH[0], RT_ELEMENTS(g_aArgDumpPH), NULL, 0, dbgcCmdDumpPageHierarchy, "[addr [cr3 [mode]]", "Dumps the paging hierarchy at for specfied address range. Guest context." }, 329 { "dphh", 0, 3, &g_aArgDumpPH[0], RT_ELEMENTS(g_aArgDumpPH), NULL, 0, dbgcCmdDumpPageHierarchy, "[addr [cr3 [mode]]", "Dumps the paging hierarchy at for specfied address range. Hypervisor context." }, 316 330 { "dpt", 1, 1, &g_aArgDumpPT[0], RT_ELEMENTS(g_aArgDumpPT), NULL, 0, dbgcCmdDumpPageTable,"<addr>", "Dumps page table entries of the default context." }, 317 331 { "dpta", 1, 1, &g_aArgDumpPTAddr[0],RT_ELEMENTS(g_aArgDumpPTAddr), NULL, 0, dbgcCmdDumpPageTable,"<addr>", "Dumps specified page table." }, … … 979 993 else 980 994 pDbgc->DisasmPos = paArgs[0]; 995 pDbgc->pLastPos = &pDbgc->DisasmPos; 981 996 982 997 /* … … 1137 1152 else 1138 1153 pDbgc->SourcePos = paArgs[0]; 1154 pDbgc->pLastPos = &pDbgc->SourcePos; 1139 1155 1140 1156 /* … … 2377 2393 } 2378 2394 2395 pDbgc->pLastPos = &pDbgc->DumpPos; 2396 2379 2397 /* 2380 2398 * Do the dumping. … … 2850 2868 2851 2869 /** 2870 * The 'dph*' commands. 2871 * 2872 * @returns VBox status. 2873 * @param pCmd Pointer to the command descriptor (as registered). 2874 * @param pCmdHlp Pointer to command helper functions. 2875 * @param pVM Pointer to the current VM (if any). 2876 * @param paArgs Pointer to (readonly) array of arguments. 2877 * @param cArgs Number of arguments in the array. 2878 */ 2879 static DECLCALLBACK(int) dbgcCmdDumpPageHierarchy(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult) 2880 { 2881 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 2882 if (!pVM) 2883 return DBGCCmdHlpFail(pCmdHlp, pCmd, "No VM.\n"); 2884 2885 /* 2886 * Figure the context. 2887 */ 2888 uint32_t fFlags = 0; 2889 if (pCmd->pszCmd[3] == '\0') 2890 fFlags |= pDbgc->fRegCtxGuest ? DBGFPGDMP_FLAGS_GUEST : DBGFPGDMP_FLAGS_SHADOW; 2891 else if (pCmd->pszCmd[3] == 'g') 2892 fFlags |= DBGFPGDMP_FLAGS_GUEST; 2893 else if (pCmd->pszCmd[3] == 'h') 2894 fFlags |= DBGFPGDMP_FLAGS_SHADOW; 2895 else 2896 fFlags |= DBGFPGDMP_FLAGS_GUEST | DBGFPGDMP_FLAGS_SHADOW; 2897 2898 /* 2899 * Get the range. 2900 */ 2901 PCDBGCVAR pRange = cArgs > 0 ? &paArgs[0] : pDbgc->pLastPos; 2902 RTGCPTR GCPtrFirst; 2903 int rc = DBGCCmdHlpVarToFlatAddr(pCmdHlp, pRange, &GCPtrFirst); 2904 if (RT_FAILURE(rc)) 2905 return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to convert %DV to a flat address: %Rrc", pRange, rc); 2906 2907 uint64_t cbRange; 2908 rc = DBGCCmdHlpVarGetRange(pCmdHlp, pRange, 1, PAGE_SIZE * 8, &cbRange); 2909 if (RT_FAILURE(rc)) 2910 return DBGCCmdHlpFail(pCmdHlp, pCmd, "Failed to obtain the range of %DV: %Rrc", pRange, rc); 2911 2912 RTGCPTR GCPtrLast = RTGCPTR_MAX - GCPtrFirst; 2913 if (cbRange >= GCPtrLast) 2914 GCPtrLast = RTGCPTR_MAX; 2915 else if (!cbRange) 2916 GCPtrLast = GCPtrFirst; 2917 else 2918 GCPtrLast = GCPtrFirst + cbRange - 1; 2919 2920 /* 2921 * Do we have a CR3? 2922 */ 2923 uint64_t cr3 = 0; 2924 if (cArgs > 1) 2925 { 2926 if ((fFlags & (DBGFPGDMP_FLAGS_GUEST | DBGFPGDMP_FLAGS_SHADOW)) == (DBGFPGDMP_FLAGS_GUEST | DBGFPGDMP_FLAGS_SHADOW)) 2927 return DBGCCmdHlpFail(pCmdHlp, pCmd, "No CR3 or mode arguments when dumping both context, please."); 2928 if (paArgs[1].enmType != DBGCVAR_TYPE_NUMBER) 2929 return DBGCCmdHlpFail(pCmdHlp, pCmd, "The CR3 argument is not a number: %DV", &paArgs[1]); 2930 cr3 = paArgs[1].u.u64Number; 2931 } 2932 else 2933 fFlags |= DBGFPGDMP_FLAGS_CURRENT_CR3; 2934 2935 /* 2936 * Do we have a mode? 2937 */ 2938 if (cArgs > 2) 2939 { 2940 if (paArgs[2].enmType != DBGCVAR_TYPE_STRING) 2941 return DBGCCmdHlpFail(pCmdHlp, pCmd, "The mode argument is not a string: %DV", &paArgs[2]); 2942 static const struct MODETOFLAGS 2943 { 2944 const char *pszName; 2945 uint32_t fFlags; 2946 } s_aModeToFlags[] = 2947 { 2948 { "ept", DBGFPGDMP_FLAGS_EPT }, 2949 { "legacy", 0 }, 2950 { "legacy-np", DBGFPGDMP_FLAGS_NP }, 2951 { "pse", DBGFPGDMP_FLAGS_PSE }, 2952 { "pse-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_NP }, 2953 { "pae", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE }, 2954 { "pae-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_NP }, 2955 { "pae-nx", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_NXE }, 2956 { "pae-nx-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_NXE | DBGFPGDMP_FLAGS_NP }, 2957 { "long", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME }, 2958 { "long-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME | DBGFPGDMP_FLAGS_NP }, 2959 { "long-nx", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME | DBGFPGDMP_FLAGS_NXE }, 2960 { "long-nx-np", DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME | DBGFPGDMP_FLAGS_NXE | DBGFPGDMP_FLAGS_NP } 2961 }; 2962 int i = RT_ELEMENTS(s_aModeToFlags); 2963 while (i-- > 0) 2964 if (!strcmp(s_aModeToFlags[i].pszName, paArgs[2].u.pszString)) 2965 { 2966 fFlags |= s_aModeToFlags[i].fFlags; 2967 break; 2968 } 2969 if (i < 0) 2970 return DBGCCmdHlpFail(pCmdHlp, pCmd, "Unknown mode: \"%s\"", paArgs[2].u.pszString); 2971 } 2972 else 2973 fFlags |= DBGFPGDMP_FLAGS_CURRENT_MODE; 2974 2975 /* 2976 * Call the worker. 2977 */ 2978 rc = DBGFR3PagingDumpEx(pVM, pDbgc->idCpu, fFlags, cr3, GCPtrFirst, GCPtrLast, 99 /*cMaxDepth*/, 2979 DBGCCmdHlpGetDbgfOutputHlp(pCmdHlp)); 2980 if (RT_FAILURE(rc)) 2981 return DBGCCmdHlpFail(pCmdHlp, pCmd, "DBGFR3PagingDumpEx: %Rrc\n", rc); 2982 return VINF_SUCCESS; 2983 } 2984 2985 2986 2987 /** 2852 2988 * The 'dpg*' commands. 2853 2989 * -
trunk/src/VBox/Debugger/DBGCInternal.h
r31530 r31966 145 145 /** Command helpers. */ 146 146 DBGCCMDHLP CmdHlp; 147 /** Wrappers for DBGF output. */ 148 DBGFINFOHLP DbgfOutputHlp; 147 149 /** Pointer to backend callback structure. */ 148 150 PDBGCBACK pBack; … … 176 178 /** Size of the previous dump element. */ 177 179 unsigned cbDumpElement; 180 /** Points to DisasmPos, SourcePos or DumpPos depending on which was 181 * used last. */ 182 PCDBGCVAR pLastPos; 178 183 179 184 /** Number of variables in papVars. */ -
trunk/src/VBox/Debugger/DBGConsole.cpp
r31530 r31966 1966 1966 //pDbgc->SourcePos = {0}; 1967 1967 //pDbgc->DumpPos = {0}; 1968 pDbgc->pLastPos = &pDbgc->DisasmPos; 1968 1969 //pDbgc->cbDumpElement = 0; 1969 1970 //pDbgc->cVars = 0; -
trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp
r31530 r31966 185 185 return VERR_INTERNAL_ERROR; 186 186 } 187 VMMDECL(int) DBGFR3PagingDumpEx(PVM pVM, VMCPUID idCpu, uint32_t fFlags, uint64_t cr3, uint64_t u64FirstAddr, 188 uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp) 189 { 190 return VERR_INTERNAL_ERROR; 191 } 187 192 VMMR3DECL(int) DBGFR3RegQueryU8( PVM pVM, VMCPUID idCpu, DBGFREG enmReg, uint8_t *pu8) 188 193 {
Note:
See TracChangeset
for help on using the changeset viewer.