Changeset 38573 in vbox
- Timestamp:
- Aug 30, 2011 2:36:20 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73751
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/err.h
r37591 r38573 1423 1423 /** No debug module interpreter matching the debug info. */ 1424 1424 #define VERR_DBG_NO_MATCHING_INTERPRETER (-667) 1425 /** Bad DWARF line number header. */ 1426 #define VERR_DWARF_BAD_LINE_NUMBER_HEADER (-668) 1427 /** Unexpected end of DWARF unit. */ 1428 #define VERR_DWARF_UNEXPECTED_END (-669) 1429 /** DWARF LEB value overflows the decoder type. */ 1430 #define VERR_DWARF_LEB_OVERFLOW (-670) 1431 /** Bad DWARF extended line number opcode. */ 1432 #define VERR_DWARF_BAD_LNE (-671) 1433 /** Bad DWARF string. */ 1434 #define VERR_DWARF_BAD_STRING (-672) 1435 /** Bad DWARF position. */ 1436 #define VERR_DWARF_BAD_POS (-673) 1425 1437 /** @} */ 1426 1438 … … 1640 1652 /** @} */ 1641 1653 1642 /** @name RTDvmstatus codes1654 /** @name Logger status codes 1643 1655 * @{ */ 1644 1656 /** The internal logger revision did not match. */ -
trunk/include/iprt/log.h
r37818 r38573 53 53 /** Default logging group. */ 54 54 RTLOGGROUP_DEFAULT, 55 RTLOGGROUP_DBG, 56 RTLOGGROUP_DBG_DWARF, 55 57 RTLOGGROUP_DIR, 56 58 RTLOGGROUP_FILE, … … 82 84 #define RT_LOGGROUP_NAMES \ 83 85 "DEFAULT", \ 86 "RT_DBG", \ 87 "RT_DBG_DWARF", \ 84 88 "RT_DIR", \ 85 89 "RT_FILE", \ … … 92 96 "RT_TIME", \ 93 97 "RT_TIMER", \ 94 "RT_11", \95 "RT_12", \96 98 "RT_13", \ 97 99 "RT_14", \ -
trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
r38558 r38573 29 29 * Header Files * 30 30 *******************************************************************************/ 31 #define LOG_GROUP RTLOGGROUP_DBG_DWARF 31 32 #include <iprt/dbg.h> 32 33 #include "internal/iprt.h" 33 34 34 35 #include <iprt/asm.h> 36 #include <iprt/ctype.h> 35 37 #include <iprt/err.h> 36 #include <iprt/ ctype.h>38 #include <iprt/log.h> 37 39 #include <iprt/mem.h> 38 40 #include <iprt/path.h> 39 #include <iprt/stream.h>40 41 #include <iprt/string.h> 41 42 #include "internal/dbgmod.h" … … 151 152 152 153 153 #define VERR_DWARF_BAD_LINE_NUMBER_HEADER -55555154 #define VERR_DWARF_UNEXPECTED_END -55554155 #define VERR_DWARF_LEB_OVERFLOW -55553156 #define VERR_DWARF_BAD_LNE -55552157 158 159 154 /** 160 155 * Loads a DWARF section from the image file. … … 455 450 /* Sign extend the value. */ 456 451 else if (u64Ret & RT_BIT_64(cBits - 1)) 457 u64Ret |= ~ RT_BIT_64(cBits- 1);452 u64Ret |= ~(RT_BIT_64(cBits - 1) - 1); 458 453 459 454 return (int64_t)u64Ret; … … 537 532 { 538 533 if (!pCursor->cbUnitLeft) 534 { 535 pCursor->rc = VERR_DWARF_BAD_STRING; 539 536 return pszErrValue; 537 } 540 538 pCursor->cbUnitLeft--; 541 539 pCursor->cbLeft--; … … 609 607 610 608 609 /** 610 * Calculates an absolute cursor position from one relative to the current 611 * cursor position. 612 * 613 * @returns The absolute cursor position. 614 * @param pCursor The cursor. 615 * @param offRelative The relative position. Must be a positive 616 * offset. 617 */ 618 static uint8_t const *rtDwarfCursor_CalcPos(PRTDWARFCURSOR pCursor, size_t offRelative) 619 { 620 if (offRelative > pCursor->cbUnitLeft) 621 { 622 pCursor->rc = VERR_DWARF_BAD_POS; 623 return NULL; 624 } 625 return pCursor->pb + offRelative; 626 } 627 628 629 /** 630 * Advances the cursor to the given position. 631 * 632 * @returns IPRT status code. 633 * @param pCursor The cursor. 634 * @param pbNewPos The new position - returned by 635 * rtDwarfCursor_CalcPos(). 636 */ 637 static int rtDwarfCursor_AdvanceToPos(PRTDWARFCURSOR pCursor, uint8_t const *pbNewPos) 638 { 639 if (RT_FAILURE(pCursor->rc)) 640 return pCursor->rc; 641 AssertPtr(pbNewPos); 642 if ((uintptr_t)pbNewPos < (uintptr_t)pCursor->pb) 643 return pCursor->rc = VERR_DWARF_BAD_POS; 644 645 uintptr_t cbAdj = (uintptr_t)pbNewPos - (uintptr_t)pCursor->pb; 646 if (RT_UNLIKELY(cbAdj > pCursor->cbUnitLeft)) 647 { 648 AssertFailed(); 649 pCursor->rc = VERR_DWARF_BAD_POS; 650 cbAdj = pCursor->cbUnitLeft; 651 } 652 653 pCursor->cbUnitLeft -= cbAdj; 654 pCursor->cbLeft -= cbAdj; 655 pCursor->pb += cbAdj; 656 return pCursor->rc; 657 } 658 659 611 660 static bool rtDwarfCursor_IsAtEndOfUnit(PRTDWARFCURSOR pCursor) 612 661 { 613 return pCursor->cbUnitLeft > 0;662 return !pCursor->cbUnitLeft; 614 663 } 615 664 … … 626 675 static bool rtDwarfCursor_IsAtEnd(PRTDWARFCURSOR pCursor) 627 676 { 628 return pCursor->cbLeft > 0;677 return !pCursor->cbLeft; 629 678 } 630 679 … … 819 868 typedef struct RTDWARFLINESTATE 820 869 { 821 /** Registers*/870 /** Virtual Line Number Machine Registers. */ 822 871 struct 823 872 { … … 837 886 /** @} */ 838 887 839 /** @name Header 840 * @{ */ 841 uint32_t uVer; 842 uint64_t cbSkipAfterHdr; 843 uint8_t cbMinInstr; 844 uint8_t cMaxOpsPerInstr; 845 uint8_t u8DefIsStmt; 846 int8_t s8LineBase; 847 uint8_t u8LineRange; 848 uint8_t u8OpcodeBase; 849 uint8_t const *pacStdOperands; 850 /** @} */ 888 /** Header. */ 889 struct 890 { 891 uint32_t uVer; 892 uint64_t offFirstOpcode; 893 uint8_t cbMinInstr; 894 uint8_t cMaxOpsPerInstr; 895 uint8_t u8DefIsStmt; 896 int8_t s8LineBase; 897 uint8_t u8LineRange; 898 uint8_t u8OpcodeBase; 899 uint8_t const *pacStdOperands; 900 } Hdr; 851 901 852 902 /** @name Include Path Table (0-based) … … 856 906 /** @} */ 857 907 858 /** @name File Name Table ( 1-based)908 /** @name File Name Table (0-based, dummy zero entry) 859 909 * @{ */ 860 910 char **papszFileNames; … … 901 951 * Sanitize the name. 902 952 */ 903 return rtDbgModDwarfStringToUtf8(pLnState->pDwarfMod, &pLnState->papszFileNames[iFileName]); 953 int rc = rtDbgModDwarfStringToUtf8(pLnState->pDwarfMod, &pLnState->papszFileNames[iFileName]); 954 Log((" File #%02u = '%s'\n", iFileName, pLnState->papszFileNames[iFileName])); 955 return rc; 904 956 } 905 957 … … 914 966 int rc = rtDbgModDwarfLinkAddressToSegOffset(pLnState->pDwarfMod, pLnState->Regs.uAddress, &iSeg, &offSeg); 915 967 if (RT_SUCCESS(rc)) 968 { 969 Log2(("rtDwarfLine_StdOp_Copy: %x:%08llx (%#llx) %s(%d)\n", iSeg, offSeg, pLnState->Regs.uAddress, pszFile, pLnState->Regs.uLine)); 916 970 rc = RTDbgModLineAdd(pLnState->pDwarfMod->hCnt, pszFile, pLnState->Regs.uLine, iSeg, offSeg, NULL); 971 972 /* Ignore address conflicts for now. */ 973 if (rc == VERR_DBG_ADDRESS_CONFLICT) 974 rc = VINF_SUCCESS; 975 } 917 976 918 977 pLnState->Regs.fBasicBlock = false; … … 936 995 pLnState->Regs.uLine = 1; 937 996 pLnState->Regs.uColumn = 0; 938 pLnState->Regs.fIsStatement = RT_BOOL(pLnState-> u8DefIsStmt);997 pLnState->Regs.fIsStatement = RT_BOOL(pLnState->Hdr.u8DefIsStmt); 939 998 pLnState->Regs.fBasicBlock = false; 940 999 pLnState->Regs.fEndSequence = false; … … 955 1014 static int rtDwarfLine_RunProgram(PRTDWARFLINESTATE pLnState, PRTDWARFCURSOR pCursor) 956 1015 { 1016 LogFlow(("rtDwarfLine_RunProgram: cbUnitLeft=%zu\n", pCursor->cbUnitLeft)); 1017 957 1018 int rc = VINF_SUCCESS; 958 1019 rtDwarfLine_ResetState(pLnState); 959 do 960 { 961 uint8_t bOpCode = rtDwarfCursor_GetUByte(pCursor, 0); 962 if (bOpCode > pLnState->u8OpcodeBase) 1020 1021 while (!rtDwarfCursor_IsAtEndOfUnit(pCursor)) 1022 { 1023 uint8_t bOpCode = rtDwarfCursor_GetUByte(pCursor, DW_LNS_extended); 1024 if (bOpCode > pLnState->Hdr.u8OpcodeBase) 963 1025 { 964 1026 /* 965 1027 * Special opcode. 966 1028 */ 967 bOpCode -= pLnState->u8OpcodeBase; 968 pLnState->Regs.uLine += bOpCode % pLnState->u8LineRange + (int32_t)pLnState->s8LineBase; 969 bOpCode /= pLnState->u8LineRange; 970 pLnState->Regs.uAddress += (pLnState->Regs.idxOp + bOpCode) / pLnState->cMaxOpsPerInstr 971 * pLnState->cbMinInstr; 972 pLnState->Regs.idxOp += (pLnState->Regs.idxOp + bOpCode) % pLnState->cMaxOpsPerInstr; 1029 uint8_t const bLogOpCode = bOpCode; NOREF(bLogOpCode); 1030 bOpCode -= pLnState->Hdr.u8OpcodeBase; 1031 1032 int32_t const cLineDelta = bOpCode % pLnState->Hdr.u8LineRange + (int32_t)pLnState->Hdr.s8LineBase; 1033 bOpCode /= pLnState->Hdr.u8LineRange; 1034 1035 uint64_t uTmp = bOpCode + pLnState->Regs.idxOp + bOpCode; 1036 uint64_t const cAddressDelta = uTmp / pLnState->Hdr.cMaxOpsPerInstr * pLnState->Hdr.cbMinInstr; 1037 uint64_t const cOpIndexDelta = uTmp % pLnState->Hdr.cMaxOpsPerInstr; 1038 1039 pLnState->Regs.uLine += cLineDelta; 1040 pLnState->Regs.uAddress += cAddressDelta; 1041 pLnState->Regs.idxOp += cOpIndexDelta; 1042 Log2(("DW Special Opcode %#04x: uLine + %d => %u; uAddress + %#llx => %#llx; idxOp + %#llx => %#llx\n", 1043 bLogOpCode, cLineDelta, pLnState->Regs.uLine, cAddressDelta, pLnState->Regs.uAddress, 1044 cOpIndexDelta, pLnState->Regs.idxOp)); 973 1045 974 1046 rc = rtDwarfLine_StdOp_Copy(pLnState); … … 982 1054 */ 983 1055 case DW_LNS_copy: 984 rtDwarfLine_StdOp_Copy(pLnState); 1056 Log2(("DW_LNS_copy\n")); 1057 rc = rtDwarfLine_StdOp_Copy(pLnState); 985 1058 break; 986 1059 … … 988 1061 { 989 1062 uint64_t u64Adv = rtDwarfCursor_GetULeb128(pCursor, 0); 990 pLnState->Regs.uAddress += (pLnState->Regs.idxOp + u64Adv) / pLnState->cMaxOpsPerInstr 991 * pLnState->cbMinInstr; 992 pLnState->Regs.idxOp += (pLnState->Regs.idxOp + u64Adv) % pLnState->cMaxOpsPerInstr; 1063 pLnState->Regs.uAddress += (pLnState->Regs.idxOp + u64Adv) / pLnState->Hdr.cMaxOpsPerInstr 1064 * pLnState->Hdr.cbMinInstr; 1065 pLnState->Regs.idxOp += (pLnState->Regs.idxOp + u64Adv) % pLnState->Hdr.cMaxOpsPerInstr; 1066 Log2(("DW_LNS_advance_pc\n")); 993 1067 break; 994 1068 } 995 1069 996 1070 case DW_LNS_advance_line: 997 pLnState->Regs.uLine += rtDwarfCursor_GetSLeb128AsS32(pCursor, 0); 1071 { 1072 int32_t cLineDelta = rtDwarfCursor_GetSLeb128AsS32(pCursor, 0); 1073 pLnState->Regs.uLine += cLineDelta; 1074 Log2(("DW_LNS_advance_line: uLine + %d => %u\n", cLineDelta, pLnState->Regs.uLine)); 998 1075 break; 1076 } 999 1077 1000 1078 case DW_LNS_set_file: 1001 1079 pLnState->Regs.iFile = rtDwarfCursor_GetULeb128AsU32(pCursor, 0); 1080 Log2(("DW_LNS_set_file: iFile=%u\n", pLnState->Regs.iFile)); 1002 1081 break; 1003 1082 1004 1083 case DW_LNS_set_column: 1005 1084 pLnState->Regs.uColumn = rtDwarfCursor_GetULeb128AsU32(pCursor, 0); 1085 Log2(("DW_LNS_set_column\n")); 1006 1086 break; 1007 1087 1008 1088 case DW_LNS_negate_stmt: 1009 1089 pLnState->Regs.fIsStatement = !pLnState->Regs.fIsStatement; 1090 Log2(("DW_LNS_negate_stmt\n")); 1010 1091 break; 1011 1092 1012 1093 case DW_LNS_set_basic_block: 1013 1094 pLnState->Regs.fBasicBlock = true; 1095 Log2(("DW_LNS_set_basic_block\n")); 1014 1096 break; 1015 1097 1016 1098 case DW_LNS_const_add_pc: 1017 pLnState->Regs.uAddress += (pLnState->Regs.idxOp + 255) / pLnState->cMaxOpsPerInstr 1018 * pLnState->cbMinInstr; 1019 pLnState->Regs.idxOp += (pLnState->Regs.idxOp + 255) % pLnState->cMaxOpsPerInstr; 1099 pLnState->Regs.uAddress += (pLnState->Regs.idxOp + 255) / pLnState->Hdr.cMaxOpsPerInstr 1100 * pLnState->Hdr.cbMinInstr; 1101 pLnState->Regs.idxOp += (pLnState->Regs.idxOp + 255) % pLnState->Hdr.cMaxOpsPerInstr; 1102 Log2(("DW_LNS_const_add_pc\n")); 1020 1103 break; 1021 1104 … … 1023 1106 pLnState->Regs.uAddress += rtDwarfCursor_GetUHalf(pCursor, 0); 1024 1107 pLnState->Regs.idxOp = 0; 1108 Log2(("DW_LNS_fixed_advance_pc\n")); 1025 1109 break; 1026 1110 1027 1111 case DW_LNS_set_prologue_end: 1028 1112 pLnState->Regs.fPrologueEnd = true; 1113 Log2(("DW_LNS_set_prologue_end\n")); 1029 1114 break; 1030 1115 1031 1116 case DW_LNS_set_epilogue_begin: 1032 1117 pLnState->Regs.fEpilogueBegin = true; 1118 Log2(("DW_LNS_set_epilogue_begin\n")); 1033 1119 break; 1034 1120 1035 1121 case DW_LNS_set_isa: 1036 1122 pLnState->Regs.uIsa = rtDwarfCursor_GetULeb128AsU32(pCursor, 0); 1123 Log2(("DW_LNS_set_isa %#x\n", pLnState->Regs.uIsa)); 1037 1124 break; 1038 1125 1039 1126 default: 1040 1127 { 1041 unsigned cOpsToSkip = pLnState->pacStdOperands[bOpCode - 1]; 1128 unsigned cOpsToSkip = pLnState->Hdr.pacStdOperands[bOpCode - 1]; 1129 Log2(("rtDwarfLine_RunProgram: Unknown standard opcode %#x, %#x operands\n", bOpCode, cOpsToSkip)); 1042 1130 while (cOpsToSkip-- > 0) 1043 1131 rc = rtDwarfCursor_SkipLeb128(pCursor); … … 1050 1138 case DW_LNS_extended: 1051 1139 { 1140 /* The instruction has a length prefix. */ 1052 1141 uint64_t cbInstr = rtDwarfCursor_GetULeb128(pCursor, UINT64_MAX); 1142 if (RT_FAILURE(pCursor->rc)) 1143 return pCursor->rc; 1053 1144 if (cbInstr > pCursor->cbUnitLeft) 1054 1145 return VERR_DWARF_BAD_LNE; 1055 /** @todo continue here. */ 1146 uint8_t const * const pbEndOfInstr = rtDwarfCursor_CalcPos(pCursor, cbInstr); 1147 1148 /* Get the opcode and deal with it if we know it. */ 1056 1149 bOpCode = rtDwarfCursor_GetUByte(pCursor, 0); 1057 1150 switch (bOpCode) 1058 1151 { 1059 1152 case DW_LNE_end_sequence: 1153 #if 0 /* No need for this */ 1154 pLnState->Regs.fEndSequence = true; 1155 rc = rtDwarfLine_StdOp_Copy(pLnState); 1156 #endif 1157 rtDwarfLine_ResetState(pLnState); 1158 Log2(("DW_LNE_end_sequence\n")); 1159 break; 1160 1060 1161 case DW_LNE_set_address: 1162 switch (cbInstr - 1) 1163 { 1164 case 2: pLnState->Regs.uAddress = rtDwarfCursor_GetU16(pCursor, UINT16_MAX); break; 1165 case 4: pLnState->Regs.uAddress = rtDwarfCursor_GetU32(pCursor, UINT32_MAX); break; 1166 case 8: pLnState->Regs.uAddress = rtDwarfCursor_GetU64(pCursor, UINT64_MAX); break; 1167 default: 1168 AssertMsgFailed(("%d\n", cbInstr)); 1169 pLnState->Regs.uAddress = rtDwarfCursor_GetUOff(pCursor, UINT64_MAX); 1170 break; 1171 } 1172 pLnState->Regs.idxOp = 0; 1173 Log2(("DW_LNE_set_address: %#llx\n", pLnState->Regs.uAddress)); 1174 break; 1175 1061 1176 case DW_LNE_define_file: 1177 { 1178 const char *pszFilename = rtDwarfCursor_GetSZ(pCursor, NULL); 1179 uint32_t idxInc = rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX); 1180 rtDwarfCursor_SkipLeb128(pCursor); /* st_mtime */ 1181 rtDwarfCursor_SkipLeb128(pCursor); /* st_size */ 1182 Log2(("DW_LNE_define_file: {%d}/%s\n", idxInc, pszFilename)); 1183 1184 rc = rtDwarfCursor_AdvanceToPos(pCursor, pbEndOfInstr); 1185 if (RT_SUCCESS(rc)) 1186 rc = rtDwarfLine_DefineFileName(pLnState, pszFilename, idxInc); 1187 } 1188 1062 1189 case DW_LNE_set_descriminator: 1190 pLnState->Regs.uDiscriminator = rtDwarfCursor_GetULeb128AsU32(pCursor, UINT32_MAX); 1191 Log2(("DW_LNE_set_descriminator: %u\n", pLnState->Regs.uDiscriminator)); 1192 break; 1193 1194 default: 1195 Log2(("rtDwarfLine_RunProgram: Unknown extended opcode %#x, length %#x\n", bOpCode, cbInstr)); 1063 1196 break; 1064 1197 } 1198 1199 /* Advance the cursor to the end of the instruction . */ 1200 rtDwarfCursor_AdvanceToPos(pCursor, pbEndOfInstr); 1065 1201 break; 1066 1202 } 1067 1203 } 1068 1204 } 1069 } while (RT_SUCCESS(rc)); 1205 1206 /* 1207 * Check the status before looping. 1208 */ 1209 if (RT_FAILURE(rc)) 1210 return rc; 1211 if (RT_FAILURE(pCursor->rc)) 1212 return pCursor->rc; 1213 } 1070 1214 return rc; 1071 1215 } … … 1081 1225 static int rtDwarfLine_ReadFileNames(PRTDWARFLINESTATE pLnState, PRTDWARFCURSOR pCursor) 1082 1226 { 1227 int rc = rtDwarfLine_DefineFileName(pLnState, "/<bad-zero-file-name-entry>", 0); 1228 if (RT_FAILURE(rc)) 1229 return rc; 1230 1083 1231 for (;;) 1084 1232 { … … 1091 1239 rtDwarfCursor_SkipLeb128(pCursor); /* st_size */ 1092 1240 1093 intrc = rtDwarfLine_DefineFileName(pLnState, psz, idxInc);1241 rc = rtDwarfLine_DefineFileName(pLnState, psz, idxInc); 1094 1242 if (RT_FAILURE(rc)) 1095 1243 return rc; 1096 1244 } 1097 return VINF_SUCCESS;1245 return pCursor->rc; 1098 1246 } 1099 1247 … … 1118 1266 pLnState->papszIncPaths = (const char **)pv; 1119 1267 } 1268 Log((" Path #%02u = '%s'\n", pLnState->cIncPaths, psz)); 1120 1269 pLnState->papszIncPaths[pLnState->cIncPaths] = psz; 1121 1270 pLnState->cIncPaths++; … … 1126 1275 } 1127 1276 1128 return VINF_SUCCESS;1277 return pCursor->rc; 1129 1278 } 1130 1279 … … 1139 1288 * Parse the header. 1140 1289 */ 1141 LnState.uVer = rtDwarfCursor_GetUHalf(pCursor, 0); 1142 if (LnState.uVer >= 2 && LnState.uVer <= 4) 1290 rtDwarfCursor_GetInitalLength(pCursor); 1291 LnState.Hdr.uVer = rtDwarfCursor_GetUHalf(pCursor, 0); 1292 if ( LnState.Hdr.uVer < 2 1293 || LnState.Hdr.uVer > 4) 1143 1294 return rtDwarfCursor_SkipUnit(pCursor); 1144 LnState.cbSkipAfterHdr = rtDwarfCursor_GetUOff(pCursor, 0); 1145 LnState.cbMinInstr = rtDwarfCursor_GetUByte(pCursor, 0); 1146 LnState.cMaxOpsPerInstr= rtDwarfCursor_GetUByte(pCursor, 0); 1147 LnState.u8DefIsStmt = rtDwarfCursor_GetUByte(pCursor, 0); 1148 LnState.s8LineBase = rtDwarfCursor_GetSByte(pCursor, 0); 1149 LnState.u8LineRange = rtDwarfCursor_GetUByte(pCursor, 0); 1150 LnState.u8OpcodeBase = rtDwarfCursor_GetUByte(pCursor, 0); 1151 if (!LnState.u8OpcodeBase) 1295 1296 LnState.Hdr.offFirstOpcode = rtDwarfCursor_GetUOff(pCursor, 0); 1297 uint8_t const * const pbFirstOpcode = rtDwarfCursor_CalcPos(pCursor, LnState.Hdr.offFirstOpcode); 1298 1299 LnState.Hdr.cbMinInstr = rtDwarfCursor_GetUByte(pCursor, 0); 1300 if (LnState.Hdr.uVer >= 4) 1301 LnState.Hdr.cMaxOpsPerInstr = rtDwarfCursor_GetUByte(pCursor, 0); 1302 else 1303 LnState.Hdr.cMaxOpsPerInstr = 1; 1304 LnState.Hdr.u8DefIsStmt = rtDwarfCursor_GetUByte(pCursor, 0); 1305 LnState.Hdr.s8LineBase = rtDwarfCursor_GetSByte(pCursor, 0); 1306 LnState.Hdr.u8LineRange = rtDwarfCursor_GetUByte(pCursor, 0); 1307 LnState.Hdr.u8OpcodeBase = rtDwarfCursor_GetUByte(pCursor, 0); 1308 1309 if ( !LnState.Hdr.u8OpcodeBase 1310 || !LnState.Hdr.cMaxOpsPerInstr 1311 || !LnState.Hdr.u8LineRange 1312 || LnState.Hdr.u8DefIsStmt > 1) 1152 1313 return VERR_DWARF_BAD_LINE_NUMBER_HEADER; 1153 1154 LnState.pacStdOperands = pCursor->pb; 1155 for (uint8_t iStdOpcode = 1; iStdOpcode < LnState.u8OpcodeBase; iStdOpcode++) 1314 Log2(("DWARF Line number header:\n" 1315 " uVer %d\n" 1316 " offFirstOpcode %#llx\n" 1317 " cbMinInstr %u\n" 1318 " cMaxOpsPerInstr %u\n" 1319 " u8DefIsStmt %u\n" 1320 " s8LineBase %d\n" 1321 " u8LineRange %u\n" 1322 " u8OpcodeBase %u\n", 1323 LnState.Hdr.uVer, LnState.Hdr.offFirstOpcode, LnState.Hdr.cbMinInstr, LnState.Hdr.cMaxOpsPerInstr, 1324 LnState.Hdr.u8DefIsStmt, LnState.Hdr.s8LineBase, LnState.Hdr.u8LineRange, LnState.Hdr.u8OpcodeBase)); 1325 1326 LnState.Hdr.pacStdOperands = pCursor->pb; 1327 for (uint8_t iStdOpcode = 1; iStdOpcode < LnState.Hdr.u8OpcodeBase; iStdOpcode++) 1156 1328 rtDwarfCursor_GetUByte(pCursor, 0); 1157 1329 1158 int rc = rtDwarfLine_ReadIncludePaths(&LnState, pCursor); 1330 int rc = pCursor->rc; 1331 if (RT_SUCCESS(rc)) 1332 rc = rtDwarfLine_ReadIncludePaths(&LnState, pCursor); 1159 1333 if (RT_SUCCESS(rc)) 1160 1334 rc = rtDwarfLine_ReadFileNames(&LnState, pCursor); … … 1163 1337 * Run the program.... 1164 1338 */ 1339 if (RT_SUCCESS(rc)) 1340 rc = rtDwarfCursor_AdvanceToPos(pCursor, pbFirstOpcode); 1165 1341 if (RT_SUCCESS(rc)) 1166 1342 rc = rtDwarfLine_RunProgram(&LnState, pCursor); … … 1198 1374 return rc; 1199 1375 1200 while ( rtDwarfCursor_IsAtEnd(&Cursor)1376 while ( !rtDwarfCursor_IsAtEnd(&Cursor) 1201 1377 && RT_SUCCESS(rc)) 1202 1378 rc = rtDbgModDwarfExplodeLineNumbersForUnit(pThis, &Cursor); … … 1259 1435 { 1260 1436 PRTDBGMODINT pMod = (PRTDBGMODINT)pvUser; 1437 Log(("Segment %.*s: LinkAddress=%#llx RVA=%#llx cb=%#llx\n", 1438 pSeg->cchName, pSeg->pchName, (uint64_t)pSeg->LinkAddress, (uint64_t)pSeg->RVA, pSeg->cb)); 1439 #if 0 1261 1440 return pMod->pDbgVt->pfnSegmentAdd(pMod, pSeg->RVA, pSeg->cb, pSeg->pchName, pSeg->cchName, 0 /*fFlags*/, NULL); 1441 #else 1442 return pMod->pDbgVt->pfnSegmentAdd(pMod, pSeg->LinkAddress, pSeg->cb, pSeg->pchName, pSeg->cchName, 0 /*fFlags*/, NULL); 1443 #endif 1262 1444 } 1263 1445 -
trunk/src/VBox/Runtime/tools/RTLdrFlt.cpp
r38547 r38573 141 141 142 142 PRTSTREAM pInput = g_pStdIn; 143 PRTSTREAM pOutput = g_pStdOut; 143 144 bool fVerbose = false; 144 145 … … 286 287 psz += cchAddress; 287 288 if (pszStart != psz) 288 RTStrmWrite( g_pStdOut, pszStart, psz - pszStart);289 RTStrmWrite(pOutput, pszStart, psz - pszStart); 289 290 pszStart = psz; 290 291 … … 297 298 { 298 299 if (iSeg != UINT32_MAX) 299 RTStrmPrintf( g_pStdOut, "=[%s:%u", RTDbgModName(hDbgMod), iSeg);300 RTStrmPrintf(pOutput, "=[%s:%u", RTDbgModName(hDbgMod), iSeg); 300 301 else 301 RTStrmPrintf( g_pStdOut, "=[%s", RTDbgModName(hDbgMod), iSeg);302 RTStrmPrintf(pOutput, "=[%s", RTDbgModName(hDbgMod), iSeg); 302 303 303 304 /* … … 310 311 { 311 312 if (!offSym) 312 RTStrmPrintf( g_pStdOut, "!%s", Symbol.szName);313 RTStrmPrintf(pOutput, "!%s", Symbol.szName); 313 314 else if (offSym > 0) 314 RTStrmPrintf( g_pStdOut, "!%s+%#llx", Symbol.szName, offSym);315 RTStrmPrintf(pOutput, "!%s+%#llx", Symbol.szName, offSym); 315 316 else 316 RTStrmPrintf( g_pStdOut, "!%s-%#llx", Symbol.szName, -offSym);317 RTStrmPrintf(pOutput, "!%s-%#llx", Symbol.szName, -offSym); 317 318 } 318 319 else 319 RTStrmPrintf( g_pStdOut, "+%#llx", u64Address - uAddr);320 RTStrmPrintf(pOutput, "+%#llx", u64Address - uAddr); 320 321 321 322 /* … … 326 327 rc = RTDbgAsLineByAddr(hDbgAs, u64Address, &offLine, &Line); 327 328 if (RT_SUCCESS(rc)) 328 RTStrmPrintf( g_pStdOut, " %Rbn(%u)", Line.szFilename, Line.uLineNo);329 330 RTStrmPrintf( g_pStdOut, "]");329 RTStrmPrintf(pOutput, " %Rbn(%u)", Line.szFilename, Line.uLineNo); 330 331 RTStrmPrintf(pOutput, "]"); 331 332 RTDbgModRelease(hDbgMod); 332 333 } … … 337 338 338 339 if (pszStart != psz) 339 RTStrmWrite( g_pStdOut, pszStart, psz - pszStart);340 RTStrmPutCh( g_pStdOut, '\n');340 RTStrmWrite(pOutput, pszStart, psz - pszStart); 341 RTStrmPutCh(pOutput, '\n'); 341 342 342 343 }
Note:
See TracChangeset
for help on using the changeset viewer.