llvm-project/lldb/source/Core
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
..
Address.cpp [lldb] Move and clean-up the Declaration class (NFC) 2021-05-04 16:34:44 +00:00
AddressRange.cpp [trace] Dedup different source lines when dumping instructions + refactor 2021-05-04 19:40:52 -07:00
AddressResolver.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
AddressResolverFileLine.cpp [lldb] Refactor argument group by SourceLocationSpec (NFCI) 2021-05-04 23:04:31 +00:00
CMakeLists.txt [lldb/Core] Add SourceLocationSpec class (NFC) 2021-05-04 16:34:45 +00:00
Communication.cpp [lldb] Don't use static locals for return value storage in some *AsCString functions 2020-07-30 12:17:42 +02:00
CoreProperties.td [lldb/Core] Change large function threshold variable into a setting. 2021-02-25 22:35:04 +01:00
Debugger.cpp Add a progress class that can track long running operations in LLDB. 2021-03-24 12:58:13 -07:00
Declaration.cpp [lldb] Move and clean-up the Declaration class (NFC) 2021-05-04 16:34:44 +00:00
Disassembler.cpp Target::ReadMemory read from read-only binary file Section, not memory 2021-04-16 16:13:07 -07:00
DumpDataExtractor.cpp [lldb] Print the fixed address if symbolication fails in DumpDataExtractor 2021-04-19 12:23:23 -07:00
DumpRegisterValue.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
DynamicLoader.cpp [lldb] Delete copy operations on PluginInterface class 2020-10-09 10:37:09 +02:00
EmulateInstruction.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
FileLineResolver.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
FileSpecList.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
FormatEntity.cpp Some FormatEntity.cpp cleanup and unit testing 2021-04-21 15:12:59 +02:00
Highlighter.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
IOHandler.cpp Migrate to llvm::unique_function instead of static member functions for callbacks 2021-03-02 16:13:54 -08:00
IOHandlerCursesGUI.cpp Target::ReadMemory read from read-only binary file Section, not memory 2021-04-16 16:13:07 -07:00
Mangled.cpp [lldb] Don't instrument demangling. 2020-12-23 10:43:13 -08:00
Module.cpp [lldb] Refactor argument group by SourceLocationSpec (NFCI) 2021-05-04 23:04:31 +00:00
ModuleChild.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
ModuleList.cpp [lldb] Access the ModuleList through iterators where possible (NFC) 2021-01-07 21:06:36 -08:00
Opcode.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
PluginManager.cpp [trace][intel-pt] Implement trace start and trace stop 2021-03-30 17:31:37 -07:00
Progress.cpp Add a progress class that can track long running operations in LLDB. 2021-03-24 12:58:13 -07:00
RichManglingContext.cpp [lldb] Fix RichManglingContext::FromCxxMethodName() leak 2021-04-21 12:32:08 -07:00
SearchFilter.cpp [lldb] Access the ModuleList through iterators where possible (NFC) 2021-01-07 21:06:36 -08:00
Section.cpp [lldb][NFC] Overload raw_ostream operator << for ConstString 2020-05-22 11:24:48 +02:00
SourceLocationSpec.cpp [lldb/Core] Add SourceLocationSpec class (NFC) 2021-05-04 16:34:45 +00:00
SourceManager.cpp [lldb] Modernize away some snprintf calls 2020-07-27 14:27:54 +02:00
StreamAsynchronousIO.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
StreamFile.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
UserSettingsController.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
Value.cpp Target::ReadMemory read from read-only binary file Section, not memory 2021-04-16 16:13:07 -07:00
ValueObject.cpp [lldb] Move and clean-up the Declaration class (NFC) 2021-05-04 16:34:44 +00:00
ValueObjectCast.cpp Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish) 2020-07-27 13:26:35 -07:00
ValueObjectChild.cpp Make the error condition in Value::ValueType explicit (NFC) 2021-02-12 16:12:31 -08:00
ValueObjectConstResult.cpp Make the error condition in Value::ValueType explicit (NFC) 2021-02-12 16:12:31 -08:00
ValueObjectConstResultCast.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
ValueObjectConstResultChild.cpp [lldb][NFC] Fix all formatting errors in .cpp file headers 2020-01-24 08:52:55 +01:00
ValueObjectConstResultImpl.cpp Make the error condition in Value::ValueType explicit (NFC) 2021-02-12 16:12:31 -08:00
ValueObjectDynamicValue.cpp Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish) 2020-07-27 13:26:35 -07:00
ValueObjectList.cpp [lldb] Delete the SharingPtr class 2020-02-11 13:23:18 +01:00
ValueObjectMemory.cpp Make the error condition in Value::ValueType explicit (NFC) 2021-02-12 16:12:31 -08:00
ValueObjectRegister.cpp Make the error condition in Value::ValueType explicit (NFC) 2021-02-12 16:12:31 -08:00
ValueObjectSyntheticFilter.cpp [lldb][NFC] Cleanup ValueObject construction code 2021-02-23 09:39:18 +01:00
ValueObjectUpdater.cpp [lldb][NFC] Rename the second ValueObjectManager to ValueObjectUpdater and remove the dead code 2021-02-24 13:58:01 +01:00
ValueObjectVariable.cpp [lldb] Move and clean-up the Declaration class (NFC) 2021-05-04 16:34:44 +00:00