This is an archive of the discontinued LLVM Phabricator instance.

[trace][intelpt] Support system-wide tracing [11] - Read warnings and perf conversion in the client
ClosedPublic

Authored by wallace on May 18 2022, 7:22 PM.

Details

Summary
  • Add logging for when the live state of the process is refreshed
  • Move error handling of the live state refreshing to Trace from TraceIntelPT. This allows refreshing to fail either at the plug-in level or at the base class level. The error is cached and it can be gotten every time RefreshLiveProcessState is invoked.
  • Allow DoRefreshLiveProcessState to handle plugin-specific parameters.
  • Add some encapsulation to prevent TraceIntelPT from accessing variables belonging to Trace.

Test done via logging:

(lldb) b main
Breakpoint 1: where = a.out`main + 20 at main.cpp:27:20, address = 0x00000000004023d9
(lldb) r
Process 2359706 launched: '/home/wallace/a.out' (x86_64)
Process 2359706 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004023d9 a.out`main at main.cpp:27:20
   24   };
   25  
   26   int main() {
-> 27     std::vector<int> vvv;
   28     for (int i = 0; i < 100000; i++)
   29       vvv.push_back(i);
   30  
(lldb) process trace start                                                                                        (lldb) log enable lldb target -F(lldb) n
Process 2359706 stopped
* thread #1, name = 'a.out', stop reason = step over
    frame #0: 0x00000000004023e8 a.out`main at main.cpp:28:12
   25  
   26   int main() {
   27     std::vector<int> vvv;
-> 28     for (int i = 0; i < 100000; i++)
   29       vvv.push_back(i);
   30  
   31     std::deque<int> dq1 = {1, 2, 3};
(lldb) thread trace dump instructions -c 2 -t                                                                     
Trace.cpp:RefreshLiveProcessState                            Trace::RefreshLiveProcessState invoked
TraceIntelPT.cpp:DoRefreshLiveProcessState                   TraceIntelPT found tsc conversion information
thread #1: tid = 2359706
  a.out`std::vector<int, std::allocator<int>>::vector() + 26 at stl_vector.h:395:19
    54: [tsc=unavailable] 0x0000000000403a7c    retq

See the logging lines at the end of the dump. They indicate that refreshing happened and that perf conversion information was found. Logging is enabled with log enable lldb target

Diff Detail

Event Timeline

wallace created this revision.May 18 2022, 7:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2022, 7:22 PM
Herald added a subscriber: pengfei. · View Herald Transcript
wallace requested review of this revision.May 18 2022, 7:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2022, 7:22 PM
wallace edited the summary of this revision. (Show Details)May 18 2022, 7:22 PM
wallace edited the summary of this revision. (Show Details)May 18 2022, 7:23 PM
jj10306 accepted this revision.May 31 2022, 5:37 PM

lgtm

This revision is now accepted and ready to land.May 31 2022, 5:37 PM

These changes (the set of [trace][intelpt] changes) broke the windows lldb bot. It's most likely this particular change, but it could be one of the others. Unfortunately, the bot had just been broken by https://reviews.llvm.org/D127882, so it didn't show the failure until that was reverted:

https://lab.llvm.org/buildbot/#/builders/83/builds/19994

yes, i'm trying to fix it now. Thanks!

Il giorno mer 15 giu 2022 alle ore 13:24 Stella Stamenova via Phabricator <
reviews@reviews.llvm.org> ha scritto:

stella.stamenova added a comment.

These changes (the set of [trace][intelpt] changes) broke the windows lldb
bot. It's most likely this particular change, but it could be one of the
others. Unfortunately, the bot had just been broken by
https://reviews.llvm.org/D127882, so it didn't show the failure until
that was reverted:

https://lab.llvm.org/buildbot/#/builders/83/builds/19994

Repository:

rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION

https://reviews.llvm.org/D125943/new/

https://reviews.llvm.org/D125943

yes, i'm trying to fix it now. Thanks!

Thanks!

One more to add to the list:

FAILED: tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/IntelPTPerThreadProcessTrace.cpp.o 
/usr/bin/g++ -DHAVE_ROUND -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/__w/1/b/llvm/Release/tools/lldb/source/Plugins/Process/Linux -I/__w/1/llvm-project/lldb/source/Plugins/Process/Linux -I/__w/1/llvm-project/lldb/include -I/__w/1/b/llvm/Release/tools/lldb/include -I/__w/1/b/llvm/Release/include -I/__w/1/llvm-project/llvm/include -I/__w/1/llvm-project/llvm/../clang/include -I/__w/1/b/llvm/Release/tools/lldb/../clang/include -I/__w/1/llvm-project/lldb/source -I/__w/1/b/llvm/Release/tools/lldb/source -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -O3 -DNDEBUG  -fno-exceptions -UNDEBUG -std=c++14 -MD -MT tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/IntelPTPerThreadProcessTrace.cpp.o -MF tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/IntelPTPerThreadProcessTrace.cpp.o.d -o tools/lldb/source/Plugins/Process/Linux/CMakeFiles/lldbPluginProcessLinux.dir/IntelPTPerThreadProcessTrace.cpp.o -c /__w/1/llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp
/__w/1/llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp: In static member function 'static llvm::Expected<std::unique_ptr<lldb_private::process_linux::IntelPTProcessTrace> > lldb_private::process_linux::IntelPTPerThreadProcessTrace::Start(const lldb_private::TraceIntelPTStartRequest&, llvm::ArrayRef<long unsigned int>)':
/__w/1/llvm-project/lldb/source/Plugins/Process/Linux/IntelPTPerThreadProcessTrace.cpp:65:10: error: could not convert 'trace' from 'lldb_private::process_linux::IntelPTProcessTraceUP {aka std::unique_ptr<lldb_private::process_linux::IntelPTProcessTrace>}' to 'llvm::Expected<std::unique_ptr<lldb_private::process_linux::IntelPTProcessTrace> >'
   return trace;
          ^~~~~

This is on CentOS with gcc 7.3.1

@stella.stamenova, I've just tried that compile command with several versions of gcc, including g++ (GCC) 8.5.0 on CentOS and got no error Sadly I couldn't install 7.3.1. Could you try again in top of tree?

@stella.stamenova, I've just tried that compile command with several versions of gcc, including g++ (GCC) 8.5.0 on CentOS and got no error Sadly I couldn't install 7.3.1. Could you try again in top of tree?

Yes, it is still failing with 7.3.1 with the same error as before.

Hi @stella.stamenova, could you help fixing that one liner? I really have
no way to install gcc7 on my linux machine (I don't have permission to
install older gcc toolchains). I'm happy to chat with you on discord or
anywhere else to get this resolved.

Il giorno gio 16 giu 2022 alle ore 08:28 Stella Stamenova via Phabricator <
reviews@reviews.llvm.org> ha scritto:

stella.stamenova added a comment.

In D125943#3587778 https://reviews.llvm.org/D125943#3587778, @wallace
wrote:

@stella.stamenova, I've just tried that compile command with several

versions of gcc, including g++ (GCC) 8.5.0 on CentOS and got no error Sadly
I couldn't install 7.3.1. Could you try again in top of tree?

Yes, it is still failing with 7.3.1 with the same error as before.

Repository:

rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION

https://reviews.llvm.org/D125943/new/

https://reviews.llvm.org/D125943