summaryrefslogtreecommitdiff
path: root/lldb/source/Target/ProcessTrace.cpp
AgeCommit message (Collapse)Author
2025-04-01[lldb] Fix intel trace plugin tests (#133826)David Peixotto
The tests for the [intel-pt](https://github.com/llvm/llvm-project/blob/348374028970c956f2e49ab7553b495d7408ccd9/lldb/docs/use/intel_pt.rst) trace plugin were failing for multiple reasons. On machines where tracing is supported many of the tests were crashing because of a nullptr dereference. It looks like the `core_file` parameter in `ProcessTrace::CreateInstance` was once ignored, but was changed to always being dereferenced. This caused the tests to fail even when tracing was supported. On machines where tracing is not supported we would still run tests that attempt to take a trace. These would obviously fail because the required hardware is not present. Note that some of the tests simply read serialized json as trace files which does not require any special hardware. This PR fixes these two issues by guarding the pointer dereference and then skipping unsupported tests on machines. With these changes the trace tests pass on both types of machines. We also add a new unit test to validate that a process can be created with a nullptr core_file through the generic process trace plugin path.
2025-01-14[lldb][NFC] Make the target's SectionLoadList private. (#113278)Greg Clayton
Lots of code around LLDB was directly accessing the target's section load list. This NFC patch makes the section load list private so the Target class can access it, but everyone else now uses accessor functions. This allows us to control the resolving of addresses and will allow for functionality in LLDB which can lazily resolve addresses in JIT plug-ins with a future patch.
2024-02-05Add a new SBProcess:: GetCoreFile() API (#80767)jeffreytan81
We have a Python script that needs to locate coredump path during debugging so that we can retrieve certain metadata files associated with it. Currently, there is no API for this. This patch adds a new `SBProcess::GetCoreFile()` to retrieve target dump file spec used for dump debugging. Note: this is different from the main executable module spec. To achieve this, the patch hoists m_core_file into PostMortemProcess for sharing. --------- Co-authored-by: jeffreytan81 <jeffreytan@fb.com>
2024-01-09[lldb] Fix a warningKazu Hirata
This patch fixes: lldb/source/Target/ProcessTrace.cpp:23:33: error: extra ';' outside of a function is incompatible with C++98 [-Werror,-Wc++98-compat-extra-semi]
2024-01-09[lldb] Fix Intel PT plugin compile errors (#77252)Nicholas Mosier
Fix #77251.
2023-12-07Fix a stall in running `quit` while a live process is running (#74687)jimingham
We need to generate events when finalizing, or we won't know that we succeeded in stopping the process to detach/kill. Instead, we stall and then after our 20 interrupt timeout, we kill the process (even if we were supposed to detach) and exit. OTOH, we have to not generate events when the Process is being destructed because shared_from_this has already been torn down, and using it will cause crashes.
2022-12-04[lldb] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-05-18[lldb] Remove non-address bits from read/write addresses in lldbDavid Spickett
Non-address bits are not part of the virtual address in a pointer. So they must be removed before passing to interfaces like ptrace. Some of them we get way with not removing, like AArch64's top byte. However this is only because of a hardware feature that ignores them. This change updates all the Process/Target Read/Write memory methods to remove non-address bits before using addresses. Doing it in this way keeps lldb-server simple and also fixes the memory caching when differently tagged pointers for the same location are read. Removing the bits is done at the ReadMemory level not DoReadMemory because particualrly for process, many subclasses override DoReadMemory. Tests have been added for read/write at the command and API level, for process and target. This includes variants like Read<sometype>FromMemory. Commands are tested to make sure we remove at the command and API level. "memory find" is not included because: * There is no API for it. * It already has its own address handling tests. Software breakpoints do use these methods but they are not tested here because there are bigger issues to fix with those. This will happen in another change. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D118794
2021-10-28[lldb] Remove ConstString from Process, ScriptInterpreter and StructuredData ↵Pavel Labath
plugin names
2021-10-18[lldb] Return StringRef from PluginInterface::GetPluginNamePavel Labath
There is no reason why this function should be returning a ConstString. While modifying these files, I also fixed several instances where GetPluginName and GetPluginNameStatic were returning different strings. I am not changing the return type of GetPluginNameStatic in this patch, as that would necessitate additional changes, and this patch is big enough as it is. Differential Revision: https://reviews.llvm.org/D111877
2021-09-13[lldb] Remove PluginInterface::GetPluginVersionPavel Labath
In all these years, we haven't found a use for this function (it has zero callers). Lets just remove the boilerplate. Differential Revision: https://reviews.llvm.org/D109600
2021-03-30[trace][intel-pt] Implement trace start and trace stopWalter Erquinigo
This implements the interactive trace start and stop methods. This diff ended up being much larger than I anticipated because, by doing it, I found that I had implemented in the beginning many things in a non optimal way. In any case, the code is much better now. There's a lot of boilerplate code due to the gdb-remote protocol, but the main changes are: - New tracing packets: jLLDBTraceStop, jLLDBTraceStart, jLLDBTraceGetBinaryData. The gdb-remote packet definitions are quite comprehensive. - Implementation of the "process trace start|stop" and "thread trace start|stop" commands. - Implementaiton of an API in Trace.h to interact with live traces. - Created an IntelPTDecoder for live threads, that use the debugger's stop id as checkpoint for its internal cache. - Added a functionality to stop the process in case "process tracing" is enabled and a new thread can't traced. - Added tests I have some ideas to unify the code paths for post mortem and live threads, but I'll do that in another diff. Differential Revision: https://reviews.llvm.org/D91679
2021-01-25[ThreadPlan] fix exec on LinuxWalter Erquinigo
2020-11-23[lldb] Prevent 'process connect' from using local-only pluginsMichał Górny
Add a 'can_connect' parameter to Process plugin initialization, and use it to filter plugins to these capable of remote connections. This is used to prevent 'process connect' from picking up a plugin that can only be used locally, e.g. the legacy FreeBSD plugin. Differential Revision: https://reviews.llvm.org/D91810
2020-11-18[trace][intel-pt] Scaffold the 'thread trace start | stop' commandsWalter Erquinigo
Depends on D90490. The stop command is simple and invokes the new method Trace::StopTracingThread(thread). On the other hand, the start command works by delegating its implementation to a CommandObject provided by the Trace plugin. This is necessary because each trace plugin needs different options for this command. There's even the chance that a Trace plugin can't support live tracing, but instead supports offline decoding and analysis, which means that "thread trace dump instructions" works but "thread trace start" doest. Because of this and a few other reasons, it's better to have each plugin provide this implementation. Besides, I'm using the GetSupportedTraceType method introduced in D90490 to quickly infer what's the trace plug-in that works for the current process. As an implementation note, I moved CommandObjectIterateOverThreads to its header so that I can use it from the IntelPT plugin. Besides, the actual start and stop logic for intel-pt is not part of this diff. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D90729
2020-11-05[trace][intel-pt] Implement the basic decoding functionalityWalter Erquinigo
Depends on D89408. This diff finally implements trace decoding! The current interface is $ trace load /path/to/trace/session/file.json $ thread trace dump instructions thread #1: tid = 3842849, total instructions = 22 [ 0] 0x40052d [ 1] 0x40052d ... [19] 0x400521 $ # simply enter, which is a repeat command [20] 0x40052d [21] 0x400529 ... This doesn't do any disassembly, which will be done in the next diff. Changes: - Added an IntelPTDecoder class, that is a wrapper for libipt, which is the actual library that performs the decoding. - Added TraceThreadDecoder class that decodes traces and memoizes the result to avoid repeating the decoding step. - Added a DecodedThread class, which represents the output from decoding and that for the time being only stores the list of reconstructed instructions. Later it'll contain the function call hierarchy, which will enable reconstructing backtraces. - Added basic APIs for accessing the trace in Trace.h: - GetInstructionCount, which counts the number of instructions traced for a given thread - IsTraceFailed, which returns an Error if decoding a thread failed - ForEachInstruction, which iterates on the instructions traced for a given thread, concealing the internal storage of threads, as plug-ins can decide to generate the instructions on the fly or to store them all in a vector, like I do. - DumpTraceInstructions was updated to print the instructions or show an error message if decoding was impossible. - Tests included Differential Revision: https://reviews.llvm.org/D89283
2020-10-19[trace] rename ThreadIntelPT into TraceTraceWalter Erquinigo
Renamed ThreadIntelPT to TreaceThread, making it a top-level class. I noticed that this class can and shuld work for any trace plugin and there's nothing intel-pt specific in it. With that TraceThread change, I was able to move most of the json file parsing logic to the base class TraceSessionFileParser, which makes adding new plug-ins easier. This originally was part of https://reviews.llvm.org/D89283 Differential Revision: https://reviews.llvm.org/D89408