llvm-project/lldb/source
Walter Erquinigo ade59d5309 [trace] Dedup different source lines when dumping instructions + refactor
When dumping the traced instructions in a for loop, like this one

  4:  for (int a = 0; a < n; a++)
  5:    do something;

there might be multiple LineEntry objects for line 4, but with different address ranges. This was causing the dump command to dump something like this:

```
  a.out`main + 11 at main.cpp:4
    [1] 0x0000000000400518    movl   $0x0, -0x8(%rbp)
    [2] 0x000000000040051f    jmp    0x400529                  ; <+28> at main.cpp:4
  a.out`main + 28 at main.cpp:4
    [3] 0x0000000000400529    cmpl   $0x3, -0x8(%rbp)
    [4] 0x000000000040052d    jle    0x400521                  ; <+20> at main.cpp:5
```

which is confusing, as main.cpp:4 appears twice consecutively.

This diff fixes that issue by making the line entry comparison strictly about the line, column and file name. Before it was also comparing the address ranges, which we don't need because our output is strictly about what the user sees in the source.

Besides, I've noticed that the logic that traverses instructions and calculates symbols and disassemblies had too much coupling, and made my changes harder to implement, so I decided to decouple it. Now there are two methods for iterating over the instruction of a trace. The existing one does it on raw load addresses, but the one provides a SymbolContext and an InstructionSP, and does the calculations efficiently (not as efficient as possible for now though), so the caller doesn't need to care about these details. I think I'll be using that iterator to reconstruct the call stacks.

I was able to fix a test with this change.

Differential Revision: https://reviews.llvm.org/D100740
2021-05-04 19:40:52 -07:00
..
API [lldb] Refactor argument group by SourceLocationSpec (NFCI) 2021-05-04 23:04:31 +00:00
Breakpoint [lldb] Refactor argument group by SourceLocationSpec (NFCI) 2021-05-04 23:04:31 +00:00
Commands Clarify the help for "breakpoint command add" and "watchpoint command add". 2021-05-03 17:22:43 -07:00
Core [trace] Dedup different source lines when dumping instructions + refactor 2021-05-04 19:40:52 -07:00
DataFormatters [lldb][NFC] Give CompilerType's IsArrayType/IsVectorType/IsBlockPointerType out-parameters default values 2021-02-23 11:15:31 +01:00
Expression Also display the underlying error message when displaying a fixit 2021-04-27 10:40:42 -07:00
Host Wrap edit line configuration calls into helper functions 2021-04-30 12:32:29 +02:00
Initialization [lldb] Fix shared library directory computation on windows 2021-02-18 15:37:52 +01:00
Interpreter [trace][intel-pt] Implement trace start and trace stop 2021-03-30 17:31:37 -07:00
Plugins [trace] Dedup different source lines when dumping instructions + refactor 2021-05-04 19:40:52 -07:00
Symbol [lldb] Refactor argument group by SourceLocationSpec (NFCI) 2021-05-04 23:04:31 +00:00
Target [trace] Dedup different source lines when dumping instructions + refactor 2021-05-04 19:40:52 -07:00
Utility [lldb] [llgs] Support owning and detaching extra processes 2021-04-24 11:08:33 +02:00
CMakeLists.txt Remove HAVE_VCS_VERSION_INC, not needed 2020-10-29 13:09:05 -07:00
lldb.cpp [lldb] Reinstate support for LLDB_VERSION_STRING 2021-02-22 16:56:00 -08:00