| 129 | } |
| 130 | |
| 131 | DbgLineData* DbgLineDataBuilder::Add(DbgCompileUnit* compileUnit, DbgLineData& lineData, DbgSrcFile* srcFile, DbgSubprogram* inlinee) |
| 132 | { |
| 133 | addr_target address = (addr_target)(lineData.mRelAddress + mDbgModule->mImageBase); |
| 134 | if ((compileUnit->mLowPC != (addr_target)-1) && ((address < (addr_target)compileUnit->mLowPC) || (address >= (addr_target)compileUnit->mHighPC))) |
| 135 | return NULL; |
| 136 | |
| 137 | if ((mCurSubprogram == NULL) || (address < mCurSubprogram->mBlock.mLowPC) || (address >= mCurSubprogram->mBlock.mHighPC)) |
| 138 | { |
| 139 | DbgSubprogramMapEntry* mapEntry = mDbgModule->mDebugTarget->mSubprogramMap.Get(address, DBG_MAX_LOOKBACK); |
| 140 | if (mapEntry != NULL) |
| 141 | { |
| 142 | mCurSubprogram = mapEntry->mEntry; |
| 143 | |
| 144 | if (address > mCurSubprogram->mBlock.mHighPC) |
| 145 | mCurSubprogram = NULL; |
| 146 | |
| 147 | if (mCurSubprogram != NULL) |
| 148 | { |
| 149 | SubprogramRecord** recordPtr = NULL; |
| 150 | if (mRecords.TryAdd(mCurSubprogram, NULL, &recordPtr)) |
| 151 | { |
| 152 | // It's not too expensive to over-reserve here, because these are just temporary structures that get copied |
| 153 | // exactly sized when we Commit |
| 154 | mCurRecord = mAlloc.Alloc<SubprogramRecord>(); |
| 155 | *recordPtr = mCurRecord; |
| 156 | mCurRecord->mContexts.mAlloc = &mAlloc; |
| 157 | mCurRecord->mContexts.Reserve(16); |
| 158 | mCurRecord->mLines.mAlloc = &mAlloc; |
| 159 | mCurRecord->mLines.Reserve(128); |
| 160 | mCurRecord->mCurContext = -1; |
| 161 | mCurRecord->mHasInlinees = false; |
| 162 | } |
| 163 | else |
| 164 | mCurRecord = *recordPtr; |
| 165 | } |
| 166 | else |
| 167 | mCurRecord = NULL; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | if (mCurSubprogram == NULL) |
| 172 | return NULL; |
| 173 | |
| 174 | bool needsNewCtx = false; |
| 175 | if (mCurRecord->mCurContext == -1) |
| 176 | { |
| 177 | needsNewCtx = true; |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | auto& curContext = mCurRecord->mContexts[mCurRecord->mCurContext]; |
| 182 | if ((curContext.mInlinee != inlinee) || (curContext.mSrcFile != srcFile)) |
| 183 | { |
| 184 | needsNewCtx = true; |
| 185 | for (int ctxIdx = 0; ctxIdx < (int)mCurRecord->mContexts.size(); ctxIdx++) |
| 186 | { |
| 187 | auto& ctx = mCurRecord->mContexts[ctxIdx]; |
| 188 | if ((ctx.mInlinee == inlinee) && (ctx.mSrcFile == srcFile)) |
no test coverage detected