[all-commits] [llvm/llvm-project] 6423b5: [trace][intel pt] Create a class for the libipt de...

walter erquinigo via All-commits all-commits at lists.llvm.org
Thu Apr 7 16:07:01 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6423b50235212db4c3a2e673b2b59fa5f6e07ec0
      https://github.com/llvm/llvm-project/commit/6423b50235212db4c3a2e673b2b59fa5f6e07ec0
  Author: Walter Erquinigo <wallace at fb.com>
  Date:   2022-04-07 (Thu, 07 Apr 2022)

  Changed paths:
    M lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
    M lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
    R lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.cpp
    R lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h
    A lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
    A lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h
    A lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.cpp
    A lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.h
    M lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h

  Log Message:
  -----------
  [trace][intel pt] Create a class for the libipt decoder wrapper

As we soon will need to decode multiple raw traces for the same thread,
having a class that encapsulates the decoding of a single raw trace is
a stepping stone that will make the coming features easier to implement.

So, I'm creating a LibiptDecoder class with that purpose. I refactored
the code and it's now much more readable. Besides that, more comments
were added. With this new structure, it's also easier to implement unit
tests.

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


  Commit: e0cfe20ad2fb8c7aab3d6e82c42649eacf595d9f
      https://github.com/llvm/llvm-project/commit/e0cfe20ad2fb8c7aab3d6e82c42649eacf595d9f
  Author: Walter Erquinigo <wallace at fb.com>
  Date:   2022-04-07 (Thu, 07 Apr 2022)

  Changed paths:
    M lldb/include/lldb/Target/Trace.h
    M lldb/source/Plugins/Trace/common/TraceSessionSaver.cpp
    M lldb/source/Plugins/Trace/common/TraceSessionSaver.h
    M lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
    M lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h
    M lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.cpp
    M lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
    M lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSessionSaver.cpp
    M lldb/source/Target/Trace.cpp

  Log Message:
  -----------
  [trace][intel pt] Create a common accessor for live and postmortem data

Some parts of the code have to distinguish between live and postmortem threads
to figure out how to get some data, e.g. thread trace buffers. This makes the
code less generic and more error prone. An example of that is that we have
two different decoders: LiveThreadDecoder and PostMortemThreadDecoder. They
exist because getting the trace bufer is different for each case.

The problem doesn't stop there. Soon we'll have even more kinds of data, like
the context switch trace, whose fetching will be different for live and post-
mortem processes.

As a way to fix this, I'm creating a common API for accessing thread data,
which is able to figure out how to handle the postmortem and live cases on
behalf of the caller. As a result of that, I was able to eliminate the two
decoders and unify them into a simpler one. Not only that, our TraceSave
functionality only worked for live threads, but now it can also work for
postmortem processes, which might be useful now, but it might in the future.

This common API is OnThreadBinaryDataRead. More information in the inline
documentation.

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


Compare: https://github.com/llvm/llvm-project/compare/47130384257a...e0cfe20ad2fb


More information about the All-commits mailing list