[all-commits] [llvm/llvm-project] f91d82: [trace] Improve the TraceCursor iteration API

walter erquinigo via All-commits all-commits at lists.llvm.org
Tue Jun 28 16:50:26 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f91d82816ff5a88a59e86b54a4d63547776d4854
      https://github.com/llvm/llvm-project/commit/f91d82816ff5a88a59e86b54a4d63547776d4854
  Author: Walter Erquinigo <wallace at fb.com>
  Date:   2022-06-28 (Tue, 28 Jun 2022)

  Changed paths:
    M lldb/include/lldb/Target/TraceCursor.h
    M lldb/include/lldb/Target/TraceInstructionDumper.h
    M lldb/source/Commands/CommandObjectThread.cpp
    M lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
    M lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
    M lldb/source/Target/TraceCursor.cpp
    M lldb/source/Target/TraceInstructionDumper.cpp

  Log Message:
  -----------
  [trace] Improve the TraceCursor iteration API

The current way ot traversing the cursor is a bit uncommon and it can't handle empty traces, in fact, its invariant is that it shold always point to a valid item. This diff simplifies the cursor API and allows it to point to invalid items, thus being able to handle empty traces or to know it ran out of data.

- Removed all the granularity functionalities, because we are not actually making use of that. We can bring them back when they are actually needed.
- change the looping logic to the following:

```
  for (; cursor->HasValue(); cursor->Next()) {
     if (cursor->IsError()) {
       .. do something for error
       continue;
     }
     .. do something for instruction
  }

```

- added a HasValue method that can be used to identify if the cursor ran out of data, the trace is empty, or the user tried to move to an invalid position via SetId() or Seek()
- made several simplifications to severals parts of the code.

Differential Revision: https://reviews.llvm.org/D128543




More information about the All-commits mailing list