[PATCH] D125783: [llvm-dva] 08 - ELF Reader

Pavel Samolysov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 03:46:37 PDT 2022


psamolysov added inline comments.


================
Comment at: llvm/lib/DebugInfo/LogicalView/Readers/LVELFReader.cpp:724
+    for (const DWARFDebugLine::Row &Row : Lines->Rows) {
+      LVLineDebug *Line = new LVLineDebug();
+      CULines.push_back(Line);
----------------
CarlosAlbertoEnciso wrote:
> psamolysov wrote:
> > An allocated in the heap `LVLineDebug` is appended into the `CULines` vector. The vector then goes into the `processLines` function and is cleared in the `LVELFReader::createScopes()` member function. I cannot find any place where the allocated `Line` is deleted.
> The best way to explain it is by looking at the following code:
> 
> ```
> // During the traversal of the debug information sections, we created the
> // logical lines representing the disassembled instructions from the text
> // section and the logical lines representing the line records from the
> // debug line section. Using the ranges associated with the logical scopes,
> // we will allocate those logical lines to their logical scopes.
> void LVBinaryReader::processLines(LVLines *DebugLines,
>                                   LVSectionIndex SectionIndex,
>                                   LVScope *Function) {
> {
>   ..
>   // Process collected lines.
>   LVScope *Scope;
>   for (LVLine *Line : *DebugLines) {
>     ..
>     // Add line object to scope.
>     Scope->addElement(Line);     <---- LineDebug/LineAssembler added to Scope
>    ..
>   }
> }
> ```
> For each `LVLine`, the function finds the `LVScope` whose address range will contain its address. Then it add that `LVLine` to that scope. The `LVLine` can be a `LVLineDebug` or `LVLineAssembler`.
> When the scope is destroyed, all its lines (`LVLineDebug` and/or `LVLineAssembler`) are deleted.
Thank you for the great explanation. I think it make sense to add a comment about a lifecycle of `LVLineDebug` instances somewhere near the `new` operator.


================
Comment at: llvm/lib/DebugInfo/LogicalView/Readers/LVELFReader.cpp:856
+    SymbolsWithLocations.clear();
+    CULines.clear();
+  }
----------------
CarlosAlbertoEnciso wrote:
> psamolysov wrote:
> > It this correct that `CULines` (a class member) is cleared after each iteration over `CompileUnits`? If there are numerous `CompileUnit`s, `CULines` will just be cleared after the first iteration.
> We start with a cleared `CULines`.
> At the end of each iteration over `CompileUnits`, `CULines` will contain all its `LVLines` for the current Compile unit `CU`.
> 
> The `LVLineDebug`s are created by `createLineAndFileRecords`
> The `LVLineAssembler`s are created by `createInstructions`
> The `CULines` are processed by `processLines`
> 
Thank you for the explanation.

Are these `LVLines` have an `owner` other than `CULines`, so a collection that stores pointers to `LVLines` (or the objects themselves) and can be used to delete `LVLines` at the end of their lifecycle?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125783/new/

https://reviews.llvm.org/D125783



More information about the llvm-commits mailing list