summaryrefslogtreecommitdiff
path: root/lldb/source/API/SBReproducer.cpp
AgeCommit message (Collapse)Author
2025-04-13[lldb] Remove vestigial remnants of reproducers (#135361)Pavel Labath
Not touching the SB API.
2022-09-19[lldb] Remove LLDB reproducersJonas Devlieghere
This patch removes the remaining reproducer code. The SBReproducer class remains for ABI stability but is just an empty shell. This completes the removal process outlined on the mailing list [1]. [1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html
2022-07-28[NFC] Improve FileSpec internal APIs and usage in preparation for adding ↵Greg Clayton
caching of resolved/absolute. Resubmission of https://reviews.llvm.org/D130309 with the 2 patches that fixed the linux buildbot, and new windows fixes. The FileSpec APIs allow users to modify instance variables directly by getting a non const reference to the directory and filename instance variables. This makes it impossible to control all of the times the FileSpec object is modified so we can clear cached member variables like m_resolved and with an upcoming patch caching if the file is relative or absolute. This patch modifies the APIs of FileSpec so no one can modify the directory or filename instance variables directly by adding set accessors and by removing the get accessors that are non const. Many clients were using FileSpec::GetCString(...) which returned a unique C string from a ConstString'ified version of the result of GetPath() which returned a std::string. This caused many locations to use this convenient function incorrectly and could cause many strings to be added to the constant string pool that didn't need to. Most clients were converted to using FileSpec::GetPath().c_str() when possible. Other clients were modified to use the newly renamed version of this function which returns an actualy ConstString: ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const; This avoids the issue where people were getting an already uniqued "const char *" that came from a ConstString only to put the "const char *" back into a "ConstString" object. By returning the ConstString instead of a "const char *" clients can be more efficient with the result. The patch: - Removes the non const GetDirectory() and GetFilename() get accessors - Adds set accessors to replace the above functions: SetDirectory() and SetFilename(). - Adds ClearDirectory() and ClearFilename() to replace usage of the FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites - Fixed all incorrect usage of FileSpec::GetCString() to use FileSpec::GetPath().c_str() where appropriate, and updated other call sites that wanted a ConstString to use the newly returned ConstString appropriately and efficiently. Differential Revision: https://reviews.llvm.org/D130549
2022-07-23Revert "[NFC] Improve FileSpec internal APIs and usage in preparation for ↵Nico Weber
adding caching of resolved/absolute." and follow-ups This reverts commit 9429b67b8e300e638d7828bbcb95585f85c4df4d. It broke the build on Windows, see comments on https://reviews.llvm.org/D130309 It also reverts these follow-ups: Revert "Fix buildbot breakage after https://reviews.llvm.org/D130309." This reverts commit f959d815f4637890ebbacca379f1c38ab47e4e14. Revert "Fix buildbot breakage after https://reviews.llvm.org/D130309." This reverts commit 0bbce7a4c2d2bff622bdadd4323f93f5d90e6d24. Revert "Cache the value for absolute path in FileSpec." This reverts commit dabe877248b85b34878e75d5510339325ee087d0.
2022-07-22[NFC] Improve FileSpec internal APIs and usage in preparation for adding ↵Greg Clayton
caching of resolved/absolute. The FileSpect APIs allow users to modify instance variables directly by getting a non const reference to the directory and filename instance variables. This makes it impossibly to control all of the times the FileSpec object is modified so we can clear the cache. This patch modifies the APIs of FileSpec so no one can modify the directory or filename directly by adding set accessors and by removing the get accessors that are non const. Many clients were using FileSpec::GetCString(...) which returned a unique C string from a ConstString'ified version of the result of GetPath() which returned a std::string. This caused many locations to use this convenient function incorrectly and could cause many strings to be added to the constant string pool that didn't need to. Most clients were converted to using FileSpec::GetPath().c_str() when possible. Other clients were modified to use the newly renamed version of this function which returns an actualy ConstString: ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const; This avoids the issue where people were getting an already uniqued "const char *" that came from a ConstString only to put the "const char *" back into a "ConstString" object. By returning the ConstString instead of a "const char *" clients can be more efficient with the result. The patch: - Removes the non const GetDirectory() and GetFilename() get accessors - Adds set accessors to replace the above functions: SetDirectory() and SetFilename(). - Adds ClearDirectory() and ClearFilename() to replace usage of the FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites - Fixed all incorrect usage of FileSpec::GetCString() to use FileSpec::GetPath().c_str() where appropriate, and updated other call sites that wanted a ConstString to use the newly returned ConstString appropriately and efficiently. Differential Revision: https://reviews.llvm.org/D130309
2022-03-03[lldb] Remove FileSystem::Initialize from FileCollectorJonas Devlieghere
This patch removes the ability to instantiate the LLDB FileSystem class with a FileCollector. It keeps the ability to collect files, but uses the FileCollectorFileSystem to do that transparently. Because the two are intertwined, this patch also removes the finalization logic which copied the files over out of process.
2022-01-20[lldb] Decouple instrumentation from the reproducersJonas Devlieghere
Remove the last remaining references to the reproducers from the instrumentation. This patch renames the relevant files and macros. Differential revision: https://reviews.llvm.org/D117712
2022-01-09[lldb] Remove reproducer instrumentationJonas Devlieghere
This patch removes most of the reproducer instrumentation. It keeps around the LLDB_RECORD_* macros for logging. See [1] for more details. [1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html Differential revision: https://reviews.llvm.org/D116847
2021-12-17[lldb] Remove reproducer replay functionalityJonas Devlieghere
This is part of a bigger rework of the reproducer feature. See [1] for more details. [1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html
2021-12-08[lldb] Make lldbVersion a full fledged libraryJonas Devlieghere
Because of its dependency on clang (and potentially other compilers downstream, such as swift) lldb_private::GetVersion already lives in its own library called lldbBase. Despite that, its implementation was spread across unrelated files. This patch improves things by introducing a Version library with its own directory, header and implementation file. The benefits of this patch include: - We can get rid of the ugly quoting macros. - Other parts of LLDB can read the version number from lldb/Version/Version.inc. - The implementation can be swapped out for tools like lldb-server than don't need to depend on clang at all. Differential revision: https://reviews.llvm.org/D115211
2021-06-17[trace][intel-pt] Create basic SB APIWalter Erquinigo
This adds a basic SB API for creating and stopping traces. Note: This doesn't add any APIs for inspecting individual instructions. That'd be a more complicated change and it might be better to enhande the dump functionality to output the data in binary format. I'll leave that for a later diff. This also enhances the existing tests so that they test the same flow using both the command interface and the SB API. I also did some cleanup of legacy code. Differential Revision: https://reviews.llvm.org/D103500
2020-10-23[lldb] Move copying of files into reproducer out of processJonas Devlieghere
For performance reasons the reproducers don't copy the files captured by the file collector eagerly, but wait until the reproducer needs to be generated. This is a problematic when LLDB crashes and we have to do all this signal-unsafe work in the signal handler. This patch uses a similar trick to clang, which has the driver invoke a new cc1 instance to do all this work out-of-process. This patch moves the writing of the mapping file as well as copying over the reproducers into a separate process spawned when lldb crashes. Differential revision: https://reviews.llvm.org/D89600
2020-09-03[lldb] Remove a stray semicolon, fixing pedantic GCC warnings. NFC.Martin Storsjö
2020-09-02[lldb] Add reproducer verifierJonas Devlieghere
Add a reproducer verifier that catches: - Missing or invalid home directory - Missing or invalid working directory - Missing or invalid module/symbol paths - Missing files from the VFS The verifier is enabled by default during replay, but can be skipped by passing --reproducer-no-verify. Differential revision: https://reviews.llvm.org/D86497
2020-09-01Revert "[lldb] Add reproducer verifier"Raphael Isemann
This reverts commit 297f69afac58fc9dc13897857a5e70131c5adc85. It broke the Fedora 33 x86-64 bot. See the review for more info.
2020-08-31[lldb] Add reproducer verifierJonas Devlieghere
Add a reproducer verifier that catches: - Missing or invalid home directory - Missing or invalid working directory - Missing or invalid module/symbol paths - Missing files from the VFS The verifier is enabled by default during replay, but can be skipped by passing --reproducer-no-verify. Differential revision: https://reviews.llvm.org/D86497
2020-08-20[lldb] Implement WorkingDirectoryProvider in terms of DirectoryProvider (NFC)Jonas Devlieghere
Add an abstract base class that can be used to create other directory providers.
2020-07-20[lldb/Reproducers] Always record the current working directoryJonas Devlieghere
Setting the current working directory in the VFS will fail if the given path doesn't exist in the YAML mapping or on disk.
2020-05-20[lldb/Reproducers] Add instrumentation to SBEnvironmentJonas Devlieghere
This class should've been instrumented when it landed. Whether the class is "highly mutable" or not doesn't affect that. With this patch TestSBEnvironment.py now passes when replayed.
2020-05-13[lldb/Reproducers] Add test-specific API to set the test CWDJonas Devlieghere
The reproducers' working directory is set to the current working directory when they are initialized. While this is not optimal, as the cwd can change during a debug session, it has been sufficient so far. The current approach doesn't work for the API test suite however because dotest temporarily changes the directory to where the test's Python file lives. This patch adds an API to tell the reproducers what to set the CWD to. This is a NO-OP in every mode but capture. Differential revision: https://reviews.llvm.org/D79825
2020-04-30[lldb/API] Move SBCommandInterpreterRunOption in its own header. (NFC)Jonas Devlieghere
Currently, `SBCommandInterpreterRunOptions` is defined in `SBCommandInterpreter.h`. Given that the options are always passed by reference, a forward declaration is sufficient. That's not the case for `SBCommandInterpreterRunResults`, which we need for a new overload for `RunCommandInterpreter` and that returns this new class by value. We can't include `SBCommandInterpreter.h` because `SBCommandInterpreter::GetDebugger()` returns SBDebugger by value and therefore needs a full definition. This patch moves the definition of `SBCommandInterpreterRunOptions` into a new header. In a later patch, `SBCommandInterpreterRunResults` will be defined in there as well, solving the aforementioned problem. Differential revision: https://reviews.llvm.org/D79115
2020-04-20[lldb/Reproducers] Support new replay mode: passive replayJonas Devlieghere
Support passive replay as proposed in the RFC [1] on lldb-dev and described in more detail on the lldb website [2]. This patch extends the LLDB_RECORD macros to re-invoke the current function with arguments deserialized from the reproducer. This relies on the function being called in the exact same order as during replay. It uses the same mechanism to toggle the API boundary as during recording, which guarantees that only boundary crossing calls are replayed. Another major change is that before this patch we could ignore the result of an API call, because we only cared about the observable behavior. Now we need to be able to return the replayed result to the SWIG bindings. We reuse a lot of the recording infrastructure, which can be a little confusing. We kept the existing naming to limit the amount of churn, but might revisit that in a future patch. [1] http://lists.llvm.org/pipermail/lldb-dev/2020-April/016100.html [2] https://lldb.llvm.org/resources/reproducers.html Differential revision: https://reviews.llvm.org/D77602
2020-04-14[lldb/Reproducers] Capture reproducers from the API test suite.Jonas Devlieghere
Make it possible to capture reproducers from the API test suite. Given the symmetry between capture and replay, this patch also adds the necessary code for replay. For now this is a NO-OP until the corresponding reproducer instrumentation changes land. For more info please refer to the RFC on lldb-dev: http://lists.llvm.org/pipermail/lldb-dev/2020-April/016100.html Differential revision: https://reviews.llvm.org/D77588
2020-03-23Revert "Create basic SBEnvironment class"Walter Erquinigo
This reverts commit fd868f517d2c5ca8c0f160dbec0857b14ecf74c1.
2020-03-23Create basic SBEnvironment classWalter Erquinigo
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2020-01-15[lldb/Reproducers] Add a flag to always generating a reproducerJonas Devlieghere
Add a flag which always generates a reproducer when normally it would be discarded. This is meant for testing purposes to capture a debugger session without modification the session itself.
2020-01-10[lldb/Reproducer] Add SBReproducer::Replay overload (again)Jonas Devlieghere
I modified the SBAPI under the assumption that nobody was using the old API yet. However, that turns out to be false. So instead of adding the deafault argument I've reintroduced the old API and made the new one an overload.
2019-12-03[lldb/Reproducer] Add version checkJonas Devlieghere
To ensure a reproducer works correctly, the version of LLDB used for capture and replay must match. Right now the reproducer already contains the LLDB version. However, this is purely informative. LLDB will happily replay a reproducer generated with a different version of LLDB, which can cause subtle differences. This patch adds a version check which compares the current LLDB version with the one in the reproducer. If the version doesn't match, LLDB will refuse to replay. It also adds an escape hatch to make it possible to still replay the reproducer without having to mess with the recorded version. This might prove useful when you know two versions of LLDB match, even though the version string doesn't. This behavior is triggered by passing a new flag -reproducer-skip-version-check to the lldb driver. Differential revision: https://reviews.llvm.org/D70934
2019-11-20[Reproducer] Generate LLDB reproducer on crashJonas Devlieghere
This patch hooks the reproducer infrastructure with the signal handlers. When lldb crashes with reproducers capture enabled, it will now generate the reproducer and print a short message the standard out. This doesn't affect the pretty stack traces, which are still printed before. This patch also introduces a new reproducer sub-command that intentionally raises a given signal to test the reproducer signal handling. Currently the signal handler is doing too much work. Instead of copying over files into the reproducers in the signal handler, we should re-invoke ourselves with a special command line flag that looks at the VFS mapping and performs the copy. This is a NO-OP when reproducers are disabled. Differential revision: https://reviews.llvm.org/D70474
2019-10-03new api class: SBFileLawrence D'Anna
Summary: SBFile is a scripting API wrapper for lldb_private::File This is the first step in a project to enable arbitrary python io.IOBase file objects -- including those that override the read() and write() methods -- to be used as the main debugger IOStreams. Currently this is impossible because python file objects must first be converted into FILE* streams by SWIG in order to be passed into the debugger. full prototype: https://github.com/smoofra/llvm-project/tree/files Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath Reviewed By: labath Subscribers: labath, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67793 llvm-svn: 373562
2019-06-12[Reproducers] Simplify providers with nested Info struct (NFC)Jonas Devlieghere
This replaces the `info` typedef with a nested struct named Info. This means we now have FooProvider and FooProvider::Info, instead of two related but separate classes FooProvider and FooInfo. This change is mostly cosmetic. llvm-svn: 363211
2019-03-19[lldb] [Reproducer] Move SBRegistry registration into declaring filesMichal Gorny
Move SBRegistry method registrations from SBReproducer.cpp into files declaring the individual APIs, in order to reduce the memory consumption during build and improve maintainability. The current humongous SBRegistry constructor exhausts all memory on a NetBSD system with 4G RAM + 4G swap, therefore making it impossible to build LLDB. Differential Revision: https://reviews.llvm.org/D59427 llvm-svn: 356481
2019-03-18[API] Remove unneded LLDB_DISABLE_PYTHON markers.Davide Italiano
llvm-svn: 356401
2019-03-12[Reproducers] Support capturing a reproducer without an explicit path.Jonas Devlieghere
Tablegen doesn't support options that are both flags and take values as an argument. I noticed this when doing the tablegen rewrite, but forgot that that affected the reproducer --capture flag. This patch makes --capture a flag and adds --capture-path to specify a path for the reproducer. In reality I expect this to be mostly used for testing, but it could be useful nonetheless. Differential revision: https://reviews.llvm.org/D59238 llvm-svn: 355936
2019-03-11Add "operator bool" to SB APIsPavel Labath
Summary: Our python version of the SB API has (the python equivalent of) operator bool, but the C++ version doesn't. This is because our python operators are added by modify-python-lldb.py, which performs postprocessing on the swig-generated interface files. In this patch, I add the "operator bool" to all SB classes which have an IsValid method (which is the same logic used by modify-python-lldb.py). This way, we make the two interfaces more constent, and it allows us to rely on swig's automatic syntesis of python __nonzero__ methods instead of doing manual fixups. Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille Subscribers: jdoerfert, lldb-commits Differential Revision: https://reviews.llvm.org/D58792 llvm-svn: 355824
2019-03-07[Reproducers] Disable registering lldb::thread_t everywhereJonas Devlieghere
As discussed on the mailing list, default serialization for thread ids is not correct, even if they're represented as basic types. I'm purposely leaving the corresponding record macros in place so that we don't break the API boundary detection. llvm-svn: 355610
2019-03-07Repair the build when LLDB_DISABLE_PYTHON is setAlex Langford
Summary: If LLDB_DISABLE_PYTHON is set, some functions are unavailable but SBReproducer assumes they are. Let's conditionally register those functions since they are conditionally declared. Differential Revision: https://reviews.llvm.org/D59056 llvm-svn: 355575
2019-03-06[Reproducers] Guard register macros that take lldb::thread_t on WindowsJonas Devlieghere
On Windows, lldb::thread_t is just a void*, so the we will try to allocate an object of type void when deserializing. Undef this for now until we support void* arguments. llvm-svn: 355519
2019-03-06[Reproducers] Don't use VLA in SBReproducer redirectJonas Devlieghere
This should unbreak the Windows bot. llvm-svn: 355518
2019-03-06[Reproducers] Enable replay from SBRepro.Jonas Devlieghere
Now that the LLDB instrumentation macros are in place, we should use that to test reproducer replay. Differential revision: https://reviews.llvm.org/D58565 llvm-svn: 355470
2019-03-06[Reproducers] Don't intercept SBDebugger::SetInputFileHandleJonas Devlieghere
With the reproducer logic in place for the command interpreter we no longer need to make SBDebugger::SetInputFileHandle a no-op. llvm-svn: 355469
2019-03-06[Reproducers] Add SBReproducer macrosJonas Devlieghere
This patch adds the SBReproducer macros needed to capture and reply the corresponding calls. This patch was generated by running the lldb-instr tool on the API source files. Differential revision: https://reviews.llvm.org/D57475 llvm-svn: 355459
2019-02-21[Reproducers] Initialize reproducers before initializing the debugger.Jonas Devlieghere
As per the discussion on the mailing list: http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20190218/048007.html This commit implements option (3): > Go back to initializing the reproducer before the rest of the debugger. > The method wouldn't be instrumented and guarantee no other SB methods are > called or SB objects are constructed. The initialization then becomes part > of the replay. Differential revision: https://reviews.llvm.org/D58410 llvm-svn: 354631
2019-02-11Update files to the new header that were incorrectly landed with the oldChandler Carruth
one. llvm-svn: 353663
2019-02-06[Reproducers] SBReproducer framework: Capture & ReplayJonas Devlieghere
This is part two of the reproducer instrumentation framework. It contains the code to capture and replay function calls. The main user of this framework will be the SB API layer. For all the details refer to the RFC on the mailing list: http://lists.llvm.org/pipermail/lldb-dev/2019-January/014530.html Differential revision: https://reviews.llvm.org/D56322 llvm-svn: 353324