aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-02-19[lldb] Synchronize the debuggers output & error streamsJonas Devlieghere1-4/+6
This patch improves the synchronization of the debugger's output and error streams using two new abstractions: `LockableStreamFile` and `LockedStreamFile`. - `LockableStreamFile` is a wrapper around a `StreamFile` and a mutex. Client cannot use the `StreamFile` without calling `Lock`, which returns a `LockedStreamFile`. - `LockedStreamFile` is an RAII object that locks the stream for the duration of its existence. As long as you hold on to the returned object you are permitted to write to the stream. The destruction of the object automatically flush the output stream.
2024-10-02[lldb] Unify implementation of CommandReturnObject::SetError(NFC) (#110707)Adrian Prantl1-1/+1
This is a cleanup that moves the API towards value semantics.
2024-08-27[lldb] Turn lldb_private::Status into a value type. (#106163)Adrian Prantl1-3/+2
This patch removes all of the Set.* methods from Status. This cleanup is part of a series of patches that make it harder use the anti-pattern of keeping a long-lives Status object around and updating it while dropping any errors it contains on the floor. This patch is largely NFC, the more interesting next steps this enables is to: 1. remove Status.Clear() 2. assert that Status::operator=() never overwrites an error 3. remove Status::operator=() Note that step (2) will bring 90% of the benefits for users, and step (3) will dramatically clean up the error handling code in various places. In the end my goal is to convert all APIs that are of the form ` ResultTy DoFoo(Status& error) ` to ` llvm::Expected<ResultTy> DoFoo() ` How to read this patch? The interesting changes are in Status.h and Status.cpp, all other changes are mostly ` perl -pi -e 's/\.SetErrorString/ = Status::FromErrorString/g' $(git grep -l SetErrorString lldb/source) ` plus the occasional manual cleanup.
2024-08-02[lldb] Eliminate more Targer* in favor of Target& in CommandObjects (NFC)Jonas Devlieghere1-3/+3
The majority of the replaced Target pointers were already used unconditionally and the few that were shouldn't even be NULL.
2024-07-31[lldb] Use Target references instead of pointers in CommandObject (NFC)Jonas Devlieghere1-4/+4
The GetTarget helper returns a Target reference so there's reason to convert it to a pointer and check its validity.
2024-07-31[lldb] Unify the way we get the Target in CommandObject (#101208)Jonas Devlieghere1-3/+3
Currently, CommandObjects are obtaining a target in a variety of ways. Often the command incorrectly operates on the selected target. As an example, when a breakpoint command is running, the current target is passed into the command but the target that hit the breakpoint is not the selected target. In other places we use the CommandObject's execution context, which is frozen during the execution of the command, and comes with its own limitations. Finally, we often want to fall back to the dummy target if no real target is available. Instead of having to guess how to get the target, this patch introduces one helper function in CommandObject to get the most relevant target. In order of priority, that's the target from the command object's execution context, from the interpreter's execution context, the selected target or the dummy target. rdar://110846511
2024-02-27Start to clean up the process of defining command arguments. (#83097)jimingham1-39/+3
Partly, there's just a lot of unnecessary boiler plate. It's also possible to define combinations of arguments that make no sense (e.g. eArgRepeatPlus followed by eArgRepeatPlain...) but these are never checked since we just push_back directly into the argument definitions. This commit is step 1 of this cleanup - do the obvious stuff. In it, all the simple homogenous argument lists and the breakpoint/watchpoint ID/Range types, are set with common functions. This is an NFC change, it just centralizes boiler plate. There's no checking yet because you can't get a single argument wrong. The end goal is that all argument definition goes through functions and m_arguments is hidden so that you can't define inconsistent argument sets.
2023-10-30[lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` return `void` ↵Pete Lawrence1-15/+10
(not `bool`) (#69991) [lldb] Part 2 of 2 - Refactor `CommandObject::DoExecute(...)` to return `void` instead of ~~`bool`~~ Justifications: - The code doesn't ultimately apply the `true`/`false` return values. - The methods already pass around a `CommandReturnObject`, typically with a `result` parameter. - Each command return object already contains: - A more precise status - The error code(s) that apply to that status Part 1 refactors the `CommandObject::Execute(...)` method. - See [https://github.com/llvm/llvm-project/pull/69989](https://github.com/llvm/llvm-project/pull/69989) rdar://117378957
2023-01-10Move from llvm::makeArrayRef to ArrayRef deduction guides - last partserge-sans-paille1-2/+2
This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141298
2022-07-14[lldb] Refactor command option enum values (NFC)Jonas Devlieghere1-30/+1
Refactor the command option enum values and the command argument table to connect the two. This has two benefits: - We guarantee that two options that use the same argument type have the same accepted values. - We can print the enum values and their description in the help output. (D129707) Differential revision: https://reviews.llvm.org/D129703
2022-03-31[LLDB] Applying clang-tidy modernize-use-equals-default over LLDBShafik Yaghmour1-2/+2
Applied modernize-use-equals-default clang-tidy check over LLDB. This check is already present in the lldb/.clang-tidy config. Differential Revision: https://reviews.llvm.org/D121844
2022-01-23[Commands] Remove redundant member initialization (NFC)Kazu Hirata1-5/+4
Identified with readability-redundant-member-init.
2021-06-17[lldb] Remove redundant calls to set eReturnStatusFailedDavid Spickett1-8/+0
This is part 2, covering the commands source. Some uses remain where it's tricky to see what the logic is or they are not used with AppendError. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D104448
2021-06-15Convert functions that were returning BreakpointOption * to BreakpointOption &.Jim Ingham1-23/+19
This is an NFC cleanup. Many of the API's that returned BreakpointOptions always returned valid ones. Internally the BreakpointLocations usually have null BreakpointOptions, since they use their owner's options until an option is set specifically on the location. So the original code used pointers & unique_ptr everywhere for consistency. But that made the code hard to reason about from the outside. This patch changes the code so that everywhere an API is guaranteed to return a non-null BreakpointOption, it returns it as a reference to make that clear. It also changes the Breakpoint to hold a BreakpointOption member where it previously had a UP. Since we were always filling the UP in the Breakpoint constructor, having the UP wasn't helping anything. Differential Revision: https://reviews.llvm.org/D104162
2021-06-09[lldb] Use C++11 default member initializersJonas Devlieghere1-10/+7
This converts a default constructor's member initializers into C++11 default member initializers. This patch was automatically generated with clang-tidy and the modernize-use-default-member-init check. $ run-clang-tidy.py -header-filter='lldb' -checks='-*,modernize-use-default-member-init' -fix This is a mass-refactoring patch and this commit will be added to .git-blame-ignore-revs. Differential revision: https://reviews.llvm.org/D103483
2021-05-03Clarify the help for "breakpoint command add" and "watchpoint command add".Jim Ingham1-1/+3
These two commands add a list of commands to the breakpoint/watchpoint. The current implementation only supports replacing the current command list. I started with that as overwrite seems to be the most common operation. But using "add" will allow us to later offer other add-modes: "prepend", "append" and "insert". That and "overwrite" then make up a useful set of options for this operation.
2021-02-09Use internal_dict everywhere we refer to the python session dict in docs.Jim Ingham1-2/+2
2021-02-09Remove trailing spaces after \ in comments.Jim Ingham1-2/+2
2021-02-09Add documentation for the extra_args parameter to breakpoint commands.Jim Ingham1-2/+10
Differential Revision: https://reviews.llvm.org/D96368
2020-12-07[LLDB] fix error message for one-line breakpoint scriptsPedro Tammela1-4/+5
LLDB is ignoring compilation errors for one-line breakpoint scripts. This patch fixes the issues and now the error message of the ScriptInterpreter is shown to the user. I had to remove a new-line character for the Lua interpreter since it was duplicated. Differential Revision: https://reviews.llvm.org/D92729
2020-09-21[lldb/Commands] Fix outdated `breakpoint command add` help stringDave Lee1-18/+15
Update the some examples in the help string for `breakpoint command add`. Python breakpoint commands have different output than what's shown in the help string. Notes: * Removed an example containing an inner function, as it seems more about a Python technique than about `command script add` * Updated `print x` to `print(x)` to be python 2/3 agnostic Differential Revision: https://reviews.llvm.org/D87807
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-1/+1
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann1-1/+1
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-14[lldb/CommandInterpreter] Remove flag that's always true (NFC)Jonas Devlieghere1-1/+0
The 'asynchronously' argument to both GetLLDBCommandsFromIOHandler and GetPythonCommandsFromIOHandler is true for all call sites. This commit simplifies the API by dropping it and giving the baton a default argument.
2019-12-21[lldb/Lua] Add missing boiler plate to ScriptInterpreter.Jonas Devlieghere1-0/+1
- Fix enum entry order. - Fix missing enum case in CommandObjectBreakpointCommand. - Add Lua entry to swtich in LanguageToString and simplify the code.
2019-12-21[lldb/Commands] Use the default scripting langauge for BP functionsJonas Devlieghere1-1/+4
When a function is used as a breakpoint command, use to the debugger's default scripting language, unless a language is explicitly specified.
2019-12-21[lldb/Commands] Honor the scripting language passedJonas Devlieghere1-2/+2
This ensures that breakpoint command honors the scripting language passed with `-s`. Currently the argument ignores the actual language and only uses it to differentiate between lldb and script commands.
2019-12-21[lldb/Commands] Fix bogus enum entry and add Lua (NFC)Jonas Devlieghere1-5/+12
Fixes a bogus enum value for the scripting language options, adds an entry for Lua and refactored the code to use an exhaustive switch.
2019-12-16[lldb][NFC] Remove unnecessary includes in source/CommandsRaphael Isemann1-4/+0
Summary: This removes most of unnecessary includes in the `source/Commands` directory. This was generated by IWYU and a script that fixed all the bogus reports from IWYU. Patch is tested on Linux and macOS. Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: krytarowski, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71489
2019-12-02[lldb][NFC] Use raw_ostream instead of Stream in Baton::GetDescriptionRaphael Isemann1-4/+4
Removing raw_ostream here is getting us closer to removing LLDB's Stream class.
2019-10-30Run clang-format on lldb/source/Commands (NFC)Adrian Prantl1-15/+16
These files had a lot of whitespace errors in them which was a constant source of merge conflicts downstream.
2019-10-25 Add the ability to pass extra args to a Python breakpoint callback.Jim Ingham1-23/+25
For example, it is pretty easy to write a breakpoint command that implements "stop when my caller is Foo", and it is pretty easy to write a breakpoint command that implements "stop when my caller is Bar". But there's no way to write a generic "stop when my caller is..." function, and then specify the caller when you add the command to a breakpoint. With this patch, you can pass this data in a SBStructuredData dictionary. That will get stored in the PythonCommandBaton for the breakpoint, and passed to the implementation function (if it has the right signature) when the breakpoint is hit. Then in lldb, you can say: (lldb) break com add -F caller_is -k caller_name -v Foo More generally this will allow us to write reusable Python breakpoint commands. Differential Revision: https://reviews.llvm.org/D68671
2019-09-27remove File::SetStream(), make new files instead.Lawrence D'Anna1-1/+1
Summary: This patch removes File::SetStream() and File::SetDescriptor(), and replaces most direct uses of File with pointers to File. Instead of calling SetStream() on a file, we make a new file and replace it. My ultimate goal here is to introduce a new API class SBFile, which has full support for python io.IOStream file objects. These can redirect read() and write() to python code, so lldb::Files will need a way to dispatch those methods. Additionally it will need some form of sharing and assigning files, as a SBFile will be passed in and assigned to the main IO streams of the debugger. In my prototype patch queue, I make File itself copyable and add a secondary class FileOps to manage the sharing and dispatch. In that case SBFile was a unique_ptr<File>. (here: https://github.com/smoofra/llvm-project/tree/files) However in review, Pavel Labath suggested that it be shared_ptr instead. (here: https://reviews.llvm.org/D67793) In order for SBFile to use shared_ptr<File>, everything else should as well. If this patch is accepted, I will make SBFile use a shared_ptr I will remove FileOps from future patches and use subclasses of File instead. Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67891 llvm-svn: 373090
2019-08-31[lldb] Unify target checking in CommandObjectRaphael Isemann1-12/+5
Summary: We currently have several CommandObjects that manually reimplement the checking for a selected target or a target in the execution context (which is the selected target when they are invoked). This patch removes all these checks and replaces them by setting the eCommandRequiresTarget flag that Pavel suggested. With this flag we are doing the same check but without having to duplicate this code in all these CommandObjects. I also added a `GetSelectedTarget()` variant of the `GetSelectedOrDummyTarget()` function to the CommandObject that checks that the flag is set and then returns a reference to the target. I didn't rewrite all the `target` variables from `Target *` to `Target &` in this patch as last time this change caused a lot of merge conflicts in Swift and I would prefer having that in a separate NFC commit. Reviewers: labath, clayborg Reviewed By: labath, clayborg Subscribers: clayborg, JDevlieghere, jingham, amccarth, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66863 llvm-svn: 370571
2019-08-26[lldb][NFC] Remove dead code that handles situations where LLDB has no dummy ↵Raphael Isemann1-22/+8
target Summary: We always have a dummy target, so any error handling regarding a missing dummy target is dead code now. Also makes the CommandObject methods that return Target& to express this fact in the API. This patch just for the CommandObject part of LLDB. I'll migrate the rest of LLDB in a follow-up patch that's WIP. Reviewers: labath Reviewed By: labath Subscribers: abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66737 llvm-svn: 369939
2019-08-22[lldb][NFC] Remove dead code that is supposed to handle invalid command optionsRaphael Isemann1-4/+2
Summary: We currently have a bunch of code that is supposed to handle invalid command options, but all this code is unreachable because invalid options are already handled in `Options::Parse`. The only way we can reach this code is when we declare but then not implement an option (which will be made impossible with D65386, which is also when we can completely remove the `default` cases). This patch replaces all this code with `llvm_unreachable` to make clear this is dead code that can't be reached. Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66522 llvm-svn: 369625
2019-08-14[LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-2/+2
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368933
2019-08-02Format OptionEnumValueElement (NFC)Jonas Devlieghere1-13/+20
Reformat OptionEnumValueElement to make it easier to distinguish between its fields. This also removes the need to disable clang-format for these arrays. Differential revision: https://reviews.llvm.org/D65489 llvm-svn: 367638
2019-07-28[lldb] Also include the array definition in CommandOptions.incRaphael Isemann1-7/+4
Summary: Right now our CommandOptions.inc only generates the initializer for the options list but not the array declaration boilerplate around it. As the array definition is identical for all arrays, we might as well also let the CommandOptions.inc generate it alongside the initializers. This patch will also allow us to generate additional declarations related to that option list in the future (e.g. a enum class representing the specific options which would make our handling code less prone). This patch also fixes a few option tables that didn't follow our naming style. Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D65331 llvm-svn: 367186
2019-07-22[lldb][NFC] Tablegenify breakpointRaphael Isemann1-10/+4
llvm-svn: 366673
2019-04-27[CommandObject] Use GetDebugger() helper method (NFC)Jonas Devlieghere1-1/+1
In r359354 a GetDebugger() method was added to the CommandObject class, so that we didn't have to go through the command interpreter to obtain the script interpreter. This patch simplifies other call sites where m_interpreter.GetDebugger() was used, and replaces them with a shorter call to the new method. llvm-svn: 359373
2019-04-26[ScriptInterpreter] Move ownership into debugger (NFC)Jonas Devlieghere1-1/+1
This is part two of the change started in r359330. This patch moves the ownership of the script interpreter from the command interpreter into the debugger. I would've preferred to remove the lazy initialization, however the fact that the scripting language is set after the debugger is created makes that tricky. So for now this does exactly the same thing as when it was under the command interpreter. The result is that this patch is fully NFC. Differential revision: https://reviews.llvm.org/D61211 llvm-svn: 359354
2019-04-10[NFC] Remove ASCII lines from commentsJonas Devlieghere1-8/+0
A lot of comments in LLDB are surrounded by an ASCII line to delimit the begging and end of the comment. Its use is not really consistent across the code base, sometimes the lines are longer, sometimes they are shorter and sometimes they are omitted. Furthermore, it looks kind of weird with the 80 column limit, where the comment actually extends past the line, but not by much. Furthermore, when /// is used for Doxygen comments, it looks particularly odd. And when // is used, it incorrectly gives the impression that it's actually a Doxygen comment. I assume these lines were added to improve distinguishing between comments and code. However, given that todays editors and IDEs do a great job at highlighting comments, I think it's worth to drop this for the sake of consistency. The alternative is fixing all the inconsistencies, which would create a lot more churn. Differential revision: https://reviews.llvm.org/D60508 llvm-svn: 358135
2019-03-10Quiet command regex instructions during batch executionDave Lee1-2/+2
Summary: Within .lldbinit, regex commands can be structured as a list of substitutions over multiple lines. It's possible that this is uninentional, but it works and has benefits. For example: command regex <command-name> s/pat1/repl1/ s/pat2/repl2/ ... I use this form of `command regex` in my `~/.lldbinit`, because it makes it clearer to write and read compared to a single line definition, because multiline substitutions don't need to be quoted, and are broken up one per line. However, multiline definitions result in usage instructions being printed for each use. The result is that every time I run `lldb`, I get a dozen or more lines of noise. With this change, the instructions are only printed when `command regex` is invoked interactively, or from a terminal, neither of which are true when lldb is sourcing `~/.lldbinit`. Reviewers: clayborg, jingham Reviewed By: clayborg Subscribers: jdoerfert, kastiglione, xiaobai, keith, lldb-commits Differential Revision: https://reviews.llvm.org/D48752 llvm-svn: 355793
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-11-11Remove header grouping comments.Jonas Devlieghere1-4/+0
This patch removes the comments grouping header includes. They were added after running IWYU over the LLDB codebase. However they add little value, are often outdates and burdensome to maintain. llvm-svn: 346626
2018-09-26Replace "nullptr-terminated" C-arrays of OptionValueEnumeration with safer ↵Tatyana Krasnukha1-11/+14
llvm::ArrayRef Differential Revision: https://reviews.llvm.org/D49017 llvm-svn: 343130
2018-08-07Move RegisterValue,Scalar,State from Core to UtilityPavel Labath1-1/+1
These three classes have no external dependencies, but they are used from various low-level APIs. Moving them down to Utility improves overall code layering (although it still does not break any particular dependency completely). The XCode project will need to be updated after this change. Differential Revision: https://reviews.llvm.org/D49740 llvm-svn: 339127
2018-04-30Reflow paragraphs in comments.Adrian Prantl1-15/+14
This is intended as a clean up after the big clang-format commit (r280751), which unfortunately resulted in many of the comment paragraphs in LLDB being very hard to read. FYI, the script I used was: import textwrap import commands import os import sys import re tmp = "%s.tmp"%sys.argv[1] out = open(tmp, "w+") with open(sys.argv[1], "r") as f: header = "" text = "" comment = re.compile(r'^( *//) ([^ ].*)$') special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$') for line in f: match = comment.match(line) if match and not special.match(match.group(2)): # skip intentionally short comments. if not text and len(match.group(2)) < 40: out.write(line) continue if text: text += " " + match.group(2) else: header = match.group(1) text = match.group(2) continue if text: filled = textwrap.wrap(text, width=(78-len(header)), break_long_words=False) for l in filled: out.write(header+" "+l+'\n') text = "" out.write(line) os.rename(tmp, sys.argv[1]) Differential Revision: https://reviews.llvm.org/D46144 llvm-svn: 331197
2018-04-10Move Args::StringTo*** functions to a new OptionArgParser classPavel Labath1-2/+4
Summary: The idea behind this is to move the functionality which depend on other lldb classes into a separate class. This way, the Args class can be turned into a lightweight arc+argv wrapper and moved into the lower lldb layers. Reviewers: jingham, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D44306 llvm-svn: 329677