- Timestamp:
- Oct 26, 2006, 1:30:27 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tools/qsysxcpt_pm.cpp
r143 r145 216 216 { 217 217 APIRET arc; 218 ULONG ulCount Pages = 1;219 ULONG ulFlags Page= 0;220 arc = DosQueryMem( (PVOID) ulValue, &ulCount Pages, &ulFlagsPage);218 ULONG ulCount = 4; 219 ULONG ulFlags = 0; 220 arc = DosQueryMem( (PVOID) ulValue, &ulCount, &ulFlags ); 221 221 222 222 if ( arc == NO_ERROR || arc == ERROR_INVALID_ADDRESS ) 223 223 { 224 224 if ( arc == NO_ERROR ) 225 fprintf( file, " flags=\"%08lX\"/>\n", ulFlagsPage ); 225 { 226 fprintf( file, " flags=\"%08lX\"", ulFlags ); 227 if ( ulFlags & (PAG_COMMIT | PAG_READ) == (PAG_COMMIT | PAG_READ) ) 228 fprintf( file, " word=\"%08lX\"/>\n", *(ULONG *) ulValue ); 229 else 230 fprintf( file, "/>\n" ); 231 } 226 232 else 227 233 fprintf( file, " flags=\"invalid\"/>\n" ); 234 } 235 else 236 { 237 fprintf( file, ">\n" ); 238 qt_excWriteErrorMsg( file, 6, "DosQueryMem returned %lu" 239 "and flags %08lX", arc, ulFlags ); 240 fprintf( file, " </Register>\n" ); 228 241 } 229 242 } … … 247 260 else 248 261 fprintf( file, " <Frame pointer=\"current\">\n" ); 249 250 if ( ulAddress ) 251 { 252 fprintf( file, " <Location address=\"%08lX\">\n", ulAddress ); 253 254 arc = DosQueryModFromEIP( &hMod, &ulObject, 255 sizeof(szMod), szMod, &ulOffset, 256 ulAddress ); 257 258 if (arc != NO_ERROR) 259 qt_excWriteErrorMsg( file, 6, "%s: DosQueryModFromEIP returned %lu", 260 szMod, arc ); 261 else 262 { 263 DosQueryModuleName( hMod, sizeof(szMod), szMod ); 264 fprintf( file, " <Module ID=\"%04lX\" name=\"", hMod ); 265 qt_excEscapeString( file, szMod ); 266 fprintf( file, "\" \n" 267 " segment=\"%04lX\" offset=\"%08lX\"/>\n", 268 ulObject + 1, ulOffset ); 262 263 fprintf( file, " <Location address=\"%08lX\">\n", ulAddress ); 264 265 arc = DosQueryModFromEIP( &hMod, &ulObject, 266 sizeof(szMod), szMod, &ulOffset, 267 ulAddress ); 268 269 if (arc != NO_ERROR) 270 qt_excWriteErrorMsg( file, 7, "%s: DosQueryModFromEIP returned %lu", 271 szMod, arc ); 272 else 273 { 274 DosQueryModuleName( hMod, sizeof(szMod), szMod ); 275 fprintf( file, " <Module ID=\"%04lX\" name=\"", hMod ); 276 qt_excEscapeString( file, szMod ); 277 fprintf( file, "\" \n" 278 " segment=\"%04lX\" offset=\"%08lX\"/>\n", 279 ulObject + 1, ulOffset ); 269 280 /// @todo (r=dmik) use .DBG and .SYM files to get symbols 270 281 // (see debug.h and debug.c from the xwphelpers package) … … 273 284 // ulObject, 274 285 // ulOffset); 275 } 276 } 277 else 278 qt_excWriteErrorMsg( file, 5, "Unable to access stack frame" ); 286 } 287 288 { 289 enum { enmDelta = 8 }; 290 UCHAR *pch = (UCHAR *) ulAddress - enmDelta; 291 UCHAR *pchEnd = (UCHAR *) ulAddress + enmDelta - 1; 292 ULONG ulCount = enmDelta * 2; 293 ULONG ulFlags = 0; 294 APIRET arc = NO_ERROR; 295 while ( 1 ) 296 { 297 arc = DosQueryMem( (void *) (ULONG) pch, &ulCount, &ulFlags ); 298 if ( arc == NO_ERROR ) 299 { 300 if ( ulCount >= enmDelta * 2 ) 301 break; 302 if ( pch + ulCount <= (UCHAR *) ulAddress ) 303 { // ulAddress is outside the pch object 304 pch += ulCount; 305 ulCount = enmDelta * 2 - ulCount; 306 } 307 else 308 { // ulAddress is within the pch object 309 pchEnd = pch += ulCount; 310 break; 311 } 312 } 313 else if ( arc == ERROR_INVALID_ADDRESS ) 314 { 315 if ( ((ULONG) pch) & 0xFFFFF000 == ulAddress & 0xFFFFF000 ) 316 break; // the same page, ulAddress inaccessible 317 pch = (UCHAR *) (ulAddress & 0xFFFFF000); 318 } 319 } 320 fprintf( file, " <Dump address=\"%08lX\">\n ", pch ); 321 if ( arc == NO_ERROR && 322 ulFlags & (PAG_COMMIT|PAG_READ) == (PAG_COMMIT | PAG_READ) ) 323 { 324 for ( ; pch < pchEnd; ++pch ) 325 fprintf( file, "%02lX%c", (ULONG) *pch, 326 ulAddress - (ULONG) pch == 1 ? '-' : ' ' ); 327 fprintf( file, "\n" ); 328 } 329 else 330 qt_excWriteErrorMsg( file, 0, "%08lX: DosQueryMem returned %lu" 331 "and flags %08lX", pch, arc, ulFlags ); 332 fprintf( file, " </Dump>\n" ); 333 } 279 334 280 335 fprintf( file, " </Location>\n" … … 303 358 { 304 359 // we're on a page boundary: check access 305 ULONG ulCount Pages= 0x1000;306 ULONG ulFlags Page= 0;307 APIRET arc = DosQueryMem( (void *) pulStackWord,308 &ulCount Pages, &ulFlagsPage);360 ULONG ulCount = 0x1000; 361 ULONG ulFlags = 0; 362 APIRET arc = DosQueryMem( (void *) pulStackWord, 363 &ulCount, &ulFlags ); 309 364 if ( (arc != NO_ERROR) 310 365 || ( arc == NO_ERROR 311 && (ulFlags Page& (PAG_COMMIT|PAG_READ))366 && (ulFlags & (PAG_COMMIT|PAG_READ)) 312 367 != (PAG_COMMIT|PAG_READ)) ) 313 368 { 314 369 fprintf( file, " <Frame pointer=\"%08lX\">\n", 315 370 (ULONG) pulStackWord ); 316 qt_excWriteErrorMsg( file, 6, 317 "Unable to access stack frame, DosQueryMem " 318 "returned %lu and flags %08lX", 319 arc, ulFlagsPage ); 371 qt_excWriteErrorMsg( file, 6, "DosQueryMem returned %lu " 372 "and flags %08lX", arc, ulFlags ); 320 373 fprintf( file, " </Frame>\n" ); 321 374 pulStackWord += 0x1000;
Note:
See TracChangeset
for help on using the changeset viewer.