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

Carlos Alberto Enciso via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 02:30:20 PDT 2022


CarlosAlbertoEnciso 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);
----------------
psamolysov wrote:
> 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.
Added the following comment for both `LVLineDebug` and `LVLineAssembler` before the `new` operator.
```
      // The 'processLines()' function will move each created logical line
      // to its enclosing logical scope, using the debug ranges information
      // and they will be released when its scope parent is deleted.
```


================
Comment at: llvm/lib/DebugInfo/LogicalView/Readers/LVELFReader.cpp:856
+    SymbolsWithLocations.clear();
+    CULines.clear();
+  }
----------------
psamolysov wrote:
> 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?
At the start the `owner` is `CULines`, but later in `processLines` they are moved to the `Lines` collection (just pointers) and are automatically deleted at the end of their `Scope` parent lifecycle..

```
class LVScope : public LVElement {
  ..
  LVAutoLines *Lines = nullptr;
  ..
};
```



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