Changeset 21107 in vbox for trunk/src/VBox/Runtime/common/dbg/dbgmodnm.cpp
- Timestamp:
- Jun 30, 2009 10:58:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgmodnm.cpp
r21047 r21107 202 202 * Try parse the stream. 203 203 */ 204 char szMod[RTDBG_SEGMENT_NAME_LENGTH] = ""; 204 RTUINTPTR SegZeroRva = fAddSymbols ? RTDbgModSegmentRva(pThis->hCnt, 0/*iSeg*/) : 0; 205 char szSym[RTDBG_SYMBOL_NAME_LENGTH] = ""; 206 size_t cchMod = 0; 207 size_t offSym = 0; 205 208 unsigned cchAddr = 0; 206 RTDBGSEGIDX iSeg = 0;207 209 uint64_t u64Low = UINT64_MAX; 208 210 uint64_t u64High = 0; … … 261 263 return VERR_DBG_NOT_LINUX_KALLSYMS; 262 264 char *pszEnd = pszModNameEnd + 1; 263 if ((size_t)(pszModNameEnd - pszModName) >= sizeof(szMod)) /* lazy bird */264 pszModNameEnd = &pszModName[sizeof(szMod)-1];265 if ((size_t)(pszModNameEnd - pszModName) >= 128) /* lazy bird */ 266 return VERR_DBG_NOT_LINUX_KALLSYMS; 265 267 *pszModNameEnd = '\0'; 266 268 if (*pszEnd) … … 272 274 273 275 /* 274 * Did the module change? If so commit the previous segment.276 * Did the module change? Then update the symbol prefix. 275 277 */ 276 if ( strcmp(pszModName, szMod) 277 && ( u64Low != UINT64_MAX 278 || u64High != 0)) 278 if ( cchMod != pszModNameEnd - pszModName 279 || memcmp(pszModName, szSym, cchMod)) 279 280 { 280 if (!fAddSymbols) 281 cchMod = pszModNameEnd - pszModName; 282 if (cchMod == 0) 283 offSym = 0; 284 else 281 285 { 282 rc = RTDbgModSegmentAdd(pThis->hCnt, u64Low, u64High - u64Low + 1, szMod[0] ? szMod : "main", 0, &iSeg);283 if (RT_FAILURE(rc))284 return rc;286 memcpy(szSym, pszModName, cchMod); 287 szSym[cchMod] = '.'; 288 offSym = cchMod + 1; 285 289 } 286 iSeg++; 287 u64Low = UINT64_MAX; 288 u64High = 0; 289 memcpy(szMod, pszModName, pszModNameEnd - pszModName + 1); 290 szSym[offSym] = '\0'; 290 291 } 291 292 … … 294 295 */ 295 296 uint32_t fFlags = 0; 296 RTDBGSEGIDX iSegSym = iSeg;297 RTDBGSEGIDX iSegSym = 0; 297 298 switch (chType) 298 299 { 299 300 /* absolute */ 300 301 case 'a': 302 case '?': /* /proc/kallsyms */ 301 303 iSegSym = RTDBGSEGIDX_ABS; 302 304 /// @todo fFlags |= RTDBG_SYM_FLAGS_LOCAL; … … 388 390 if (fAddSymbols) 389 391 { 390 rc = RTDbgModSymbolAdd(pThis->hCnt, pszName, iSeg, u64Addr - RTDbgModSegmentRva(pThis->hCnt, iSeg), 0, fFlags, NULL); 391 if (RT_FAILURE(rc)) 392 size_t cchName = pszNameEnd - pszName; 393 if (cchName >= sizeof(szSym) - offSym) 394 cchName = sizeof(szSym) - offSym - 1; 395 memcpy(&szSym[offSym], pszName, cchName + 1); 396 if (iSegSym == 0) 397 rc = RTDbgModSymbolAdd(pThis->hCnt, szSym, iSegSym, u64Addr - SegZeroRva, 0/*cb*/, fFlags, NULL); 398 else 399 rc = RTDbgModSymbolAdd(pThis->hCnt, szSym, iSegSym, u64Addr, 0/*cb*/, fFlags, NULL); 400 if ( RT_FAILURE(rc) 401 && rc != VERR_DBG_DUPLICATE_SYMBOL 402 && rc != VERR_DBG_ADDRESS_CONFLICT) /* (don't be too strict) */ 392 403 return rc; 393 404 } 394 405 395 406 /* Track segment span. */ 396 if (iSegSym == iSeg)407 if (iSegSym == 0) 397 408 { 398 409 if (u64Low > u64Addr) … … 435 446 if (rc == VERR_EOF) 436 447 { 437 if ( !fAddSymbols 438 && ( u64Low != UINT64_MAX 439 || u64High != 0)) 440 rc = RTDbgModSegmentAdd(pThis->hCnt, u64Low, u64High - u64Low + 1, szMod[0] ? szMod : "main", 0, &iSeg); 448 if (fAddSymbols) 449 rc = VINF_SUCCESS; 441 450 else 442 rc = VINF_SUCCESS; 451 { 452 if ( u64Low != UINT64_MAX 453 || u64High != 0) 454 rc = RTDbgModSegmentAdd(pThis->hCnt, u64Low, u64High - u64Low + 1, "main", 0, NULL); 455 else /* No sensible symbols... throw an error instead? */ 456 rc = RTDbgModSegmentAdd(pThis->hCnt, 0, 0, "main", 0, NULL); 457 } 443 458 } 444 459
Note:
See TracChangeset
for help on using the changeset viewer.