Changeset 5731 in vbox for trunk/src/VBox
- Timestamp:
- Nov 13, 2007 10:42:00 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 26101
- Location:
- trunk/src/VBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/DBGCCmdHlp.cpp
r5686 r5731 270 270 default: 271 271 rc = pCmdHlp->pfnPrintf(pCmdHlp, NULL, "error: %Vrc: %s", rc, pszFormat ? " " : "\n"); 272 if ( VBOX_SUCCESS(rc) && pszFormat)272 if (RT_SUCCESS(rc) && pszFormat) 273 273 rc = pCmdHlp->pfnPrintfV(pCmdHlp, NULL, pszFormat, args); 274 if (RT_SUCCESS(rc)) 275 rc = VERR_DBGC_COMMAND_FAILED; 274 276 break; 275 277 } -
trunk/src/VBox/Debugger/DBGCCmdWorkers.cpp
r5686 r5731 53 53 54 54 /** @todo move me!*/ 55 void dbgcVarInit(PDBGCVAR pVar) 56 { 57 if (pVar) 58 { 59 memset(pVar, 0, sizeof(*pVar)); 60 AssertCompile(DBGCVAR_TYPE_UNKNOWN == 0); 61 AssertCompile(DBGCVAR_RANGE_NONE == 0); 62 } 63 } 64 65 66 /** @todo move me!*/ 55 67 void dbgcVarSetGCFlat(PDBGCVAR pVar, RTGCPTR GCFlat) 56 68 { … … 58 70 { 59 71 pVar->enmType = DBGCVAR_TYPE_GC_FLAT; 72 memset(&pVar->u, 0, sizeof(pVar->u)); 60 73 pVar->u.GCFlat = GCFlat; 61 74 pVar->enmRangeType = DBGCVAR_RANGE_NONE; … … 71 84 { 72 85 pVar->enmType = DBGCVAR_TYPE_GC_FLAT; 86 memset(&pVar->u, 0, sizeof(pVar->u)); 73 87 pVar->u.GCFlat = GCFlat; 74 88 pVar->enmRangeType = DBGCVAR_RANGE_BYTES; 75 89 pVar->u64Range = cb; 90 } 91 } 92 93 94 /** @todo move me!*/ 95 void dbgcVarSetU64(PDBGCVAR pVar, uint64_t u64) 96 { 97 if (pVar) 98 { 99 pVar->enmType = DBGCVAR_TYPE_NUMBER; 100 memset(&pVar->u, 0, sizeof(pVar->u)); 101 pVar->u.u64Number = u64; 102 pVar->enmRangeType = DBGCVAR_RANGE_NONE; 103 pVar->u64Range = 0; 76 104 } 77 105 } … … 95 123 } 96 124 125 /** @todo move me!*/ 126 void dbgcVarSetDbgfAddr(PDBGCVAR pVar, PCDBGFADDRESS pAddress) 127 { 128 if (pVar) 129 { 130 memset(&pVar->u, 0, sizeof(pVar->u)); 131 132 Assert(!pAddress || DBGFADDRESS_IS_VALID(pAddress)); 133 if (pAddress && DBGFADDRESS_IS_VALID(pAddress)) 134 { 135 switch (pAddress->fFlags & DBGFADDRESS_FLAGS_TYPE_MASK) 136 { 137 case DBGFADDRESS_FLAGS_FAR16: 138 case DBGFADDRESS_FLAGS_FAR32: 139 case DBGFADDRESS_FLAGS_FAR64: 140 pVar->enmType = DBGCVAR_TYPE_GC_FAR; 141 pVar->u.GCFar.off = pAddress->off; 142 pVar->u.GCFar.sel = pAddress->Sel; 143 break; 144 145 case DBGFADDRESS_FLAGS_FLAT: 146 pVar->enmType = DBGCVAR_TYPE_GC_FLAT; 147 pVar->u.GCFlat = pAddress->FlatPtr; 148 break; 149 150 case DBGFADDRESS_FLAGS_PHYS: 151 pVar->enmType = DBGCVAR_TYPE_GC_PHYS; 152 pVar->u.GCPhys = pAddress->FlatPtr; 153 break; 154 155 default: 156 AssertFailed(); 157 pVar->enmType = DBGCVAR_TYPE_UNKNOWN; 158 break; 159 } 160 } 161 else 162 pVar->enmType = DBGCVAR_TYPE_UNKNOWN; 163 pVar->enmRangeType = DBGCVAR_RANGE_NONE; 164 pVar->u64Range = 0; 165 } 166 } 167 97 168 98 169 /** @todo move me!*/ … … 141 212 case DBGCVAR_TYPE_GC_FAR: 142 213 return DBGFR3AddrFromSelOff(pDbgc->pVM, pAddress, pVar->u.GCFar.sel, pVar->u.GCFar.sel); 214 215 case DBGCVAR_TYPE_GC_PHYS: 216 DBGFR3AddrFromPhys(pDbgc->pVM, pAddress, pVar->u.GCPhys); 217 return VINF_SUCCESS; 143 218 144 219 case DBGCVAR_TYPE_STRING: … … 152 227 } 153 228 154 case DBGCVAR_TYPE_GC_PHYS:155 229 case DBGCVAR_TYPE_HC_FLAT: 156 230 case DBGCVAR_TYPE_HC_FAR: -
trunk/src/VBox/Debugger/DBGCEmulateCodeView.cpp
r5671 r5731 68 68 static DECLCALLBACK(int) dbgcCmdRegTerse(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 69 69 static DECLCALLBACK(int) dbgcCmdSearchMem(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 70 static DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 70 71 static DECLCALLBACK(int) dbgcCmdStack(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 71 72 static DECLCALLBACK(int) dbgcCmdTrace(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); … … 229 230 /** 's' arguments. */ 230 231 static const DBGCVARDESC g_aArgSearchMem[] = 232 { 233 /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ 234 { 0, 1, DBGCVAR_CAT_OPTION, 0, "-b", "Byte string." }, 235 { 0, 1, DBGCVAR_CAT_OPTION, 0, "-w", "Word string." }, 236 { 0, 1, DBGCVAR_CAT_OPTION, 0, "-d", "DWord string." }, 237 { 0, 1, DBGCVAR_CAT_OPTION, 0, "-q", "QWord string." }, 238 { 0, 1, DBGCVAR_CAT_OPTION, 0, "-a", "ASCII string." }, 239 { 0, 1, DBGCVAR_CAT_OPTION, 0, "-u", "Unicode string." }, 240 { 0, 1, DBGCVAR_CAT_OPTION_NUMBER, 0, "-n <Hits>", "Maximum number of hits." }, 241 { 0, 1, DBGCVAR_CAT_GC_POINTER, 0, "range", "Register to show or set." }, 242 { 0, ~0, DBGCVAR_CAT_ANY, 0, "pattern", "Pattern to search for." }, 243 }; 244 245 246 /** 's?' arguments. */ 247 static const DBGCVARDESC g_aArgSearchMemType[] = 231 248 { 232 249 /* cTimesMin, cTimesMax, enmCategory, fFlags, pszName, pszDescription */ … … 294 311 { "rh", 0, 2, &g_aArgReg[0], RT_ELEMENTS(g_aArgReg), NULL, 0, dbgcCmdRegHyper, "[reg [newval]]", "Show or set register(s) - hypervisor reg set." }, 295 312 { "rt", 0, 0, NULL, 0, NULL, 0, dbgcCmdRegTerse, "", "Toggles terse / verbose register info." }, 296 //{ "s", 2, ~0, &g_aArgSearchMem[0],RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "<range> <pattern>","Continue last search." },297 { "sa", 2, ~0, &g_aArgSearchMem [0],RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "<range> <pattern>", "Search memory for an ascii string." },298 { "sb", 2, ~0, &g_aArgSearchMem [0],RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "<range> <pattern>", "Search memory for one or more bytes." },299 { "sd", 2, ~0, &g_aArgSearchMem [0],RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "<range> <pattern>", "Search memory for one or more double words." },300 { "sq", 2, ~0, &g_aArgSearchMem [0],RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "<range> <pattern>", "Search memory for one or more quad words." },301 { "su", 2, ~0, &g_aArgSearchMem [0],RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "<range> <pattern>", "Search memory for an unicode string." },302 { "sw", 2, ~0, &g_aArgSearchMem [0],RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "<range> <pattern>", "Search memory for one or more words." },313 { "s", 0, ~0, &g_aArgSearchMem[0], RT_ELEMENTS(g_aArgSearchMem), NULL, 0, dbgcCmdSearchMem, "[options] <range> <pattern>", "Continue last search." }, 314 { "sa", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for an ascii string." }, 315 { "sb", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more bytes." }, 316 { "sd", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more double words." }, 317 { "sq", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more quad words." }, 318 { "su", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for an unicode string." }, 319 { "sw", 2, ~0, &g_aArgSearchMemType[0], RT_ELEMENTS(g_aArgSearchMemType), NULL, 0, dbgcCmdSearchMemType, "<range> <pattern>", "Search memory for one or more words." }, 303 320 { "t", 0, 0, NULL, 0, NULL, 0, dbgcCmdTrace, "", "Instruction trace (step into)." }, 304 321 { "u", 0, 1, &g_aArgUnassemble[0],RT_ELEMENTS(g_aArgUnassemble),NULL, 0, dbgcCmdUnassemble, "[addr]", "Unassemble." }, … … 2809 2826 2810 2827 /** 2828 * Converts one or more variables into a byte buffer for a 2829 * given unit size. 2830 * 2831 * @returns VBox status codes: 2832 * @retval VERR_TOO_MUCH_DATA if the buffer is too small, bitched. 2833 * @retval VERR_INTERNAL_ERROR on bad variable type, bitched. 2834 * @retval VINF_SUCCESS on success. 2835 * 2836 * @param pvBuf The buffer to convert into. 2837 * @param pcbBuf The buffer size on input. The size of the result on output. 2838 * @param cbUnit The unit size to apply when converting. 2839 * @param paVars The array of variables to convert. 2840 * @param cVars The number of variables. 2841 */ 2842 int dbgcVarsToBytes(PDBGCCMDHLP pCmdHlp, void *pvBuf, uint32_t *pcbBuf, size_t cbUnit, PCDBGCVAR paVars, unsigned cVars) 2843 { 2844 union 2845 { 2846 uint8_t *pu8; 2847 uint16_t *pu16; 2848 uint32_t *pu32; 2849 uint64_t *pu64; 2850 } u, uEnd; 2851 u.pu8 = (uint8_t *)pvBuf; 2852 uEnd.pu8 = u.pu8 + *pcbBuf; 2853 2854 unsigned i; 2855 for (i = 0; i < cVars && u.pu8 < uEnd.pu8; i++) 2856 { 2857 switch (paVars[i].enmType) 2858 { 2859 case DBGCVAR_TYPE_GC_FAR: 2860 case DBGCVAR_TYPE_HC_FAR: 2861 case DBGCVAR_TYPE_GC_FLAT: 2862 case DBGCVAR_TYPE_GC_PHYS: 2863 case DBGCVAR_TYPE_HC_FLAT: 2864 case DBGCVAR_TYPE_HC_PHYS: 2865 case DBGCVAR_TYPE_NUMBER: 2866 { 2867 uint64_t u64 = paVars[i].u.u64Number; 2868 switch (cbUnit) 2869 { 2870 case 1: 2871 do 2872 { 2873 *u.pu8++ = u64; 2874 u64 >>= 8; 2875 } while (u64); 2876 break; 2877 case 2: 2878 do 2879 { 2880 *u.pu16++ = u64; 2881 u64 >>= 16; 2882 } while (u64); 2883 break; 2884 case 4: 2885 *u.pu32++ = u64; 2886 u64 >>= 32; 2887 if (u64) 2888 *u.pu32++ = u64; 2889 break; 2890 case 8: 2891 *u.pu64++ = u64; 2892 break; 2893 } 2894 break; 2895 } 2896 2897 case DBGCVAR_TYPE_STRING: 2898 case DBGCVAR_TYPE_SYMBOL: 2899 { 2900 const char *psz = paVars[i].u.pszString; 2901 size_t cbString = strlen(psz); 2902 if (cbString > (uintptr_t)(uEnd.pu8 - u.pu8)) 2903 cbString = uEnd.pu8 - u.pu8; 2904 2905 size_t cbCopy = cbString & ~(cbUnit - 1); 2906 memcpy(u.pu8, psz, cbCopy); 2907 u.pu8 += cbCopy; 2908 psz += cbCopy; 2909 2910 size_t cbReminder = cbString & (cbUnit - 1); 2911 if (cbReminder) 2912 { 2913 memcpy(u.pu8, psz, cbString & (cbUnit - 1)); 2914 memset(u.pu8 + cbReminder, 0, cbUnit - cbReminder); 2915 u.pu8 += cbUnit; 2916 } 2917 break; 2918 } 2919 2920 default: 2921 *pcbBuf = u.pu8 - (uint8_t *)pvBuf; 2922 pCmdHlp->pfnVBoxError(pCmdHlp, VERR_INTERNAL_ERROR, 2923 "i=%d enmType=%d\n", i, paVars[i].enmType); 2924 return VERR_INTERNAL_ERROR; 2925 } 2926 } 2927 *pcbBuf = u.pu8 - (uint8_t *)pvBuf; 2928 if (i != cVars) 2929 { 2930 pCmdHlp->pfnVBoxError(pCmdHlp, VERR_TOO_MUCH_DATA, "Max %d bytes.\n", uEnd.pu8 - (uint8_t *)pvBuf); 2931 return VERR_TOO_MUCH_DATA; 2932 } 2933 return VINF_SUCCESS; 2934 } 2935 2936 2937 /** 2938 * Executes the search. 2939 * 2940 * @returns VBox status code. 2941 * @param pCmdHlp The command helpers. 2942 * @param pVM The VM handle. 2943 * @param pAddress The address to start searching from. (undefined on output) 2944 * @param cbRange The address range to search. Must not wrap. 2945 * @param pabBytes The byte pattern to search for. 2946 * @param cbBytes The size of the pattern. 2947 * @param cbUnit The search unit. 2948 * @param cMaxHits The max number of hits. 2949 * @param pResult Where to store the result if it's a function invocation. 2950 */ 2951 static int dbgcCmdWorkerSearchMemDoIt(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGFADDRESS pAddress, RTGCUINTPTR cbRange, 2952 const uint8_t *pabBytes, uint32_t cbBytes, 2953 uint32_t cbUnit, uint64_t cMaxHits, PDBGCVAR pResult) 2954 { 2955 /* 2956 * Do the search. 2957 */ 2958 uint64_t cHits = 0; 2959 for (;;) 2960 { 2961 /* search */ 2962 DBGFADDRESS HitAddress; 2963 int rc = DBGFR3MemScan(pVM, pAddress, cbRange, pabBytes, cbBytes, &HitAddress); 2964 if (RT_FAILURE(rc)) 2965 { 2966 if (rc != VERR_DBGF_MEM_NOT_FOUND) 2967 return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "DBGFR3MemScan\n"); 2968 2969 /* update the current address so we can save it (later). */ 2970 pAddress->off += cbRange; 2971 pAddress->FlatPtr += cbRange; 2972 cbRange = 0; 2973 break; 2974 } 2975 2976 /* report result */ 2977 DBGCVAR VarCur; 2978 dbgcVarInit(&VarCur); 2979 dbgcVarSetDbgfAddr(&VarCur, &HitAddress); 2980 if (!pResult) 2981 pCmdHlp->pfnExec(pCmdHlp, "db %DV LB 10", &VarCur); 2982 else 2983 dbgcVarSetDbgfAddr(pResult, &HitAddress); 2984 2985 /* advance */ 2986 cbRange -= HitAddress.FlatPtr - pAddress->FlatPtr; 2987 *pAddress = HitAddress; 2988 pAddress->FlatPtr += cbBytes; 2989 pAddress->off += cbBytes; 2990 if (cbRange <= cbBytes) 2991 { 2992 cbRange = 0; 2993 break; 2994 } 2995 cbRange -= cbBytes; 2996 2997 if (++cHits >= cMaxHits) 2998 { 2999 /// @todo save the search. 3000 break; 3001 } 3002 } 3003 3004 /* 3005 * Save the search so we can resume it... 3006 */ 3007 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 3008 if (pDbgc->abSearch != pabBytes) 3009 { 3010 memcpy(pDbgc->abSearch, pabBytes, cbBytes); 3011 pDbgc->cbSearch = cbBytes; 3012 pDbgc->cbSearchUnit = cbUnit; 3013 } 3014 pDbgc->cMaxSearchHits = cMaxHits; 3015 pDbgc->SearchAddr = *pAddress; 3016 pDbgc->cbSearchRange = cbRange; 3017 3018 return cHits ? VINF_SUCCESS : VERR_DBGC_COMMAND_FAILED; 3019 } 3020 3021 3022 /** 3023 * Resumes the previous search. 3024 * 3025 * @returns VBox status code. 3026 * @param pCmdHlp Pointer to the command helper functions. 3027 * @param pVM Pointer to the current VM (if any). 3028 * @param pResult Where to store the result of a function invocation. 3029 */ 3030 static int dbgcCmdWorkerSearchMemResume(PDBGCCMDHLP pCmdHlp, PVM pVM, PDBGCVAR pResult) 3031 { 3032 PDBGC pDbgc = DBGC_CMDHLP2DBGC(pCmdHlp); 3033 3034 /* 3035 * Make sure there is a previous command. 3036 */ 3037 if (!pDbgc->cbSearch) 3038 { 3039 pCmdHlp->pfnPrintf(pCmdHlp, NULL, "Error: No previous search\n"); 3040 return VERR_DBGC_COMMAND_FAILED; 3041 } 3042 3043 /* 3044 * Make range and address adjustments. 3045 */ 3046 DBGFADDRESS Address = pDbgc->SearchAddr; 3047 if (Address.FlatPtr == ~(RTGCUINTPTR)0) 3048 { 3049 Address.FlatPtr -= Address.off; 3050 Address.off = 0; 3051 } 3052 3053 RTGCUINTPTR cbRange = pDbgc->cbSearchRange; 3054 if (!cbRange) 3055 cbRange = ~(RTGCUINTPTR)0; 3056 if (Address.FlatPtr + cbRange < pDbgc->SearchAddr.FlatPtr) 3057 cbRange = ~(RTGCUINTPTR)0 - pDbgc->SearchAddr.FlatPtr + !!pDbgc->SearchAddr.FlatPtr; 3058 3059 return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pVM, &Address, cbRange, pDbgc->abSearch, pDbgc->cbSearch, 3060 pDbgc->cbSearchUnit, pDbgc->cMaxSearchHits, pResult); 3061 } 3062 3063 3064 /** 3065 * Search memory, worker for the 's' and 's?' functions. 3066 * 3067 * @returns VBox status. 3068 * @param pCmdHlp Pointer to the command helper functions. 3069 * @param pVM Pointer to the current VM (if any). 3070 * @param pAddress Where to start searching. If no range, search till end of address space. 3071 * @param cMaxHits The maximum number of hits. 3072 * @param chType The search type. 3073 * @param paPatArgs The pattern variable array. 3074 * @param cPatArgs Number of pattern variables. 3075 * @param pResult Where to store the result of a function invocation. 3076 */ 3077 static int dbgcCmdWorkerSearchMem(PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR pAddress, uint64_t cMaxHits, char chType, 3078 PCDBGCVAR paPatArgs, unsigned cPatArgs, PDBGCVAR pResult) 3079 { 3080 dbgcVarSetGCFlat(pResult, 0); 3081 3082 /* 3083 * Convert the search pattern into bytes and DBGFR3MemScan can deal with. 3084 */ 3085 uint32_t cbUnit; 3086 switch (chType) 3087 { 3088 case 'a': 3089 case 'b': cbUnit = 1; break; 3090 case 'u': 3091 case 'w': cbUnit = 2; break; 3092 case 'd': cbUnit = 4; break; 3093 case 'q': cbUnit = 8; break; 3094 default: 3095 return pCmdHlp->pfnVBoxError(pCmdHlp, VERR_INVALID_PARAMETER, "chType=%c\n", chType); 3096 } 3097 uint8_t abBytes[RT_SIZEOFMEMB(DBGC, abSearch)]; 3098 uint32_t cbBytes = sizeof(abBytes); 3099 int rc = dbgcVarsToBytes(pCmdHlp, abBytes, &cbBytes, cbUnit, paPatArgs, cPatArgs); 3100 if (RT_FAILURE(rc)) 3101 return VERR_DBGC_COMMAND_FAILED; 3102 3103 /* 3104 * Make DBGF address and fix the range. 3105 */ 3106 DBGFADDRESS Address; 3107 rc = pCmdHlp->pfnVarToDbgfAddr(pCmdHlp, pAddress, &Address); 3108 if (RT_FAILURE(rc)) 3109 return pCmdHlp->pfnVBoxError(pCmdHlp, rc, "VarToDbgfAddr(,%Dv,)\n", pAddress); 3110 3111 RTGCUINTPTR cbRange; 3112 switch (pAddress->enmRangeType) 3113 { 3114 case DBGCVAR_RANGE_BYTES: 3115 cbRange = pAddress->u64Range; 3116 if (cbRange != pAddress->u64Range) 3117 cbRange = ~(RTGCUINTPTR)0; 3118 break; 3119 3120 case DBGCVAR_RANGE_ELEMENTS: 3121 cbRange = (RTGCUINTPTR)(pAddress->u64Range * cbUnit); 3122 if ( cbRange != pAddress->u64Range * cbUnit 3123 || cbRange < pAddress->u64Range) 3124 cbRange = ~(RTGCUINTPTR)0; 3125 break; 3126 3127 default: 3128 cbRange = ~(RTGCUINTPTR)0; 3129 break; 3130 } 3131 if (Address.FlatPtr + cbRange < Address.FlatPtr) 3132 cbRange = ~(RTGCUINTPTR)0 - Address.FlatPtr + !!Address.FlatPtr; 3133 3134 /* 3135 * Ok, do it. 3136 */ 3137 return dbgcCmdWorkerSearchMemDoIt(pCmdHlp, pVM, &Address, cbRange, abBytes, cbBytes, cbUnit, cMaxHits, pResult); 3138 } 3139 3140 3141 /** 2811 3142 * The 's' command. 2812 3143 * … … 2821 3152 { 2822 3153 /* check that the parser did what it's supposed to do. */ 2823 if ( cArgs != 1 2824 || paArgs[0].enmType != DBGCVAR_TYPE_STRING) 3154 //if ( cArgs <= 2 3155 // && paArgs[0].enmType != DBGCVAR_TYPE_STRING) 3156 // return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "parser error\n"); 3157 3158 /* 3159 * Repeate previous search? 3160 */ 3161 if (cArgs == 0) 3162 return dbgcCmdWorkerSearchMemResume(pCmdHlp, pVM, pResult); 3163 3164 /* 3165 * Parse arguments. 3166 */ 3167 3168 return -1; 3169 } 3170 3171 3172 /** 3173 * The 's?' command. 3174 * 3175 * @returns VBox status. 3176 * @param pCmd Pointer to the command descriptor (as registered). 3177 * @param pCmdHlp Pointer to command helper functions. 3178 * @param pVM Pointer to the current VM (if any). 3179 * @param paArgs Pointer to (readonly) array of arguments. 3180 * @param cArgs Number of arguments in the array. 3181 */ 3182 static DECLCALLBACK(int) dbgcCmdSearchMemType(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult) 3183 { 3184 /* check that the parser did what it's supposed to do. */ 3185 if ( cArgs < 2 3186 || !DBGCVAR_ISGCPOINTER(paArgs[0].enmType)) 2825 3187 return pCmdHlp->pfnPrintf(pCmdHlp, NULL, "parser error\n"); 2826 return -1;3188 return dbgcCmdWorkerSearchMem(pCmdHlp, pVM, &paArgs[0], pResult ? 1 : 80, pCmd->pszCmd[1], paArgs + 1, cArgs - 1, pResult); 2827 3189 } 2828 3190 -
trunk/src/VBox/Debugger/DBGCInternal.h
r5686 r5731 64 64 #define VERR_DBGC_BP_EXISTS (-12004) 65 65 #define VINF_DBGC_BP_NO_COMMAND 12005 66 #define VERR_DBGC_COMMAND_FAILED (-12006) 66 67 67 68 … … 159 160 /** The list of breakpoints. (singly linked) */ 160 161 PDBGCBP pFirstBp; 162 163 /** Save search pattern. */ 164 uint8_t abSearch[256]; 165 /** The length of the search pattern. */ 166 uint32_t cbSearch; 167 /** The search unit */ 168 uint32_t cbSearchUnit; 169 /** The max hits. */ 170 uint64_t cMaxSearchHits; 171 /** The address to resume searching from. */ 172 DBGFADDRESS SearchAddr; 173 /** What's left of the original search range. */ 174 RTGCUINTPTR cbSearchRange; 161 175 162 176 /** @name Parsing and Execution … … 337 351 int dbgcBpExec(PDBGC pDbgc, RTUINT iBp); 338 352 353 void dbgcVarInit(PDBGCVAR pVar); 339 354 void dbgcVarSetGCFlat(PDBGCVAR pVar, RTGCPTR GCFlat); 340 355 void dbgcVarSetGCFlatByteRange(PDBGCVAR pVar, RTGCPTR GCFlat, uint64_t cb); 356 void dbgcVarSetU64(PDBGCVAR pVar, uint64_t u64); 341 357 void dbgcVarSetVar(PDBGCVAR pVar, PCDBGCVAR pVar2); 358 void dbgcVarSetDbgfAddr(PDBGCVAR pVar, PCDBGFADDRESS pAddress); 342 359 void dbgcVarSetNoRange(PDBGCVAR pVar); 343 360 void dbgcVarSetByteRange(PDBGCVAR pVar, uint64_t cb); -
trunk/src/VBox/Debugger/DBGConsole.cpp
r5686 r5731 1260 1260 rc = pCmd->pfnHandler(pCmd, &pDbgc->CmdHlp, pDbgc->pVM, &pDbgc->aArgs[0], cArgs, NULL); 1261 1261 pDbgc->rcCmd = rc; 1262 if (rc == VERR_DBGC_COMMAND_FAILED) 1263 rc = VINF_SUCCESS; 1262 1264 } 1263 1265 else … … 1343 1345 rc = pDbgc->CmdHlp.pfnPrintf(&pDbgc->CmdHlp, NULL, 1344 1346 "Error: Cannot get symbol, it's set only (argument %d).\n", cArgs); 1347 break; 1348 1349 case VERR_DBGC_COMMAND_FAILED: 1350 rc = VINF_SUCCESS; 1345 1351 break; 1346 1352 … … 1355 1361 */ 1356 1362 if (rc >= VERR_PARSE_FIRST && rc < VERR_PARSE_LAST) 1357 rc = 0;1363 rc = VINF_SUCCESS; 1358 1364 } 1359 1365 … … 1941 1947 //pDbgc->paVars = NULL; 1942 1948 //pDbgc->pFirstBp = NULL; 1949 //pDbgc->abSearch = {0}; 1950 //pDbgc->cbSearch = 0; 1951 pDbgc->cbSearchUnit = 1; 1952 pDbgc->cMaxSearchHits = 1; 1953 //pDbgc->SearchAddr = {0}; 1954 //pDbgc->cbSearchRange = 0; 1955 1943 1956 //pDbgc->uInputZero = 0; 1944 1957 //pDbgc->iRead = 0; -
trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp
r5685 r5731 275 275 return VERR_INTERNAL_ERROR; 276 276 } 277 277 DBGFR3DECL(int) DBGFR3MemScan(PVM pVM, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress) 278 { 279 return VERR_INTERNAL_ERROR; 280 } 281 DBGFR3DECL(void) DBGFR3AddrFromPhys(PVM pVM, PDBGFADDRESS pAddress, RTGCPHYS PhysAddr) 282 { 283 } -
trunk/src/VBox/VMM/DBGFMem.cpp
r5667 r5731 84 84 * Scan guest memory for an exact byte string. 85 85 * 86 * @returns VBox status code. 86 * @returns VBox status codes: 87 * @retval VINF_SUCCESS and *pGCPtrHit on success. 88 * @retval VERR_DBGF_MEM_NOT_FOUND if not found. 89 * @retval VERR_INVALID_POINTER if any of the pointer arguments are invalid. 90 * @retval VERR_INVALID_ARGUMENT if any other arguments are invalid. 91 * 87 92 * @param pVM The VM handle. 88 93 * @param pAddress Where to store the mixed address. -
trunk/src/VBox/VMM/PGMDbg.cpp
r5667 r5731 264 264 break; 265 265 cb = pbEnd - pb; 266 if (cb <= cbNeedle)266 if (cb >= cbNeedle) 267 267 { 268 268 /* match? */ … … 325 325 if (!cbNeedle) 326 326 return VERR_INVALID_PARAMETER; 327 if (cb Range > MAX_NEEDLE_SIZE)327 if (cbNeedle > MAX_NEEDLE_SIZE) 328 328 return VERR_INVALID_PARAMETER; 329 329 … … 370 370 { 371 371 PPGMPAGE pPage = &pRam->aPages[iPage]; 372 if ( !PGM_PAGE_IS_ZERO(pPage)373 && !PGM_PAGE_IS_MMIO(pPage))372 if ( /** @todo !PGM_PAGE_IS_ZERO(pPage) 373 &&*/ !PGM_PAGE_IS_MMIO(pPage)) 374 374 { 375 375 void const *pvPage; … … 437 437 if (!cbNeedle) 438 438 return VERR_INVALID_PARAMETER; 439 if (cb Range > MAX_NEEDLE_SIZE)439 if (cbNeedle > MAX_NEEDLE_SIZE) 440 440 return VERR_INVALID_PARAMETER; 441 441 … … 456 456 while (cPages-- > 0) 457 457 { 458 uint64_t fFlags;459 458 RTGCPHYS GCPhys; 460 int rc = PGM GstGetPage(pVM, GCPtr, &fFlags, &GCPhys);459 int rc = PGMPhysGCPtr2GCPhys(pVM, GCPtr, &GCPhys); 461 460 if (RT_SUCCESS(rc)) 462 461 { 463 462 PPGMPAGE pPage = pgmPhysGetPage(&pVM->pgm.s, GCPhys); 464 463 if ( pPage 465 && !PGM_PAGE_IS_ZERO(pPage)464 ///@todo && !PGM_PAGE_IS_ZERO(pPage) 466 465 && !PGM_PAGE_IS_MMIO(pPage)) 467 466 { 468 467 void const *pvPage; 469 468 PGMPAGEMAPLOCK Lock; 470 rc = PGMPhysGCPhys2CCPtrReadOnly(pVM, GCP tr& ~(RTGCUINTPTR)PAGE_OFFSET_MASK, &pvPage, &Lock);469 rc = PGMPhysGCPhys2CCPtrReadOnly(pVM, GCPhys & ~(RTGCUINTPTR)PAGE_OFFSET_MASK, &pvPage, &Lock); 471 470 if (RT_SUCCESS(rc)) 472 471 {
Note:
See TracChangeset
for help on using the changeset viewer.