summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/breakpoint/breakpoint_command
AgeCommit message (Collapse)Author
2024-05-23[lldb][Windows] Fixed the TestBreakpointCommand test (#93122)Dmitry Vasilyev
The TestBreakpointCommand test is incorrectly disabled for Windows target. We can disable it for Windows host instead or just fix the issue. This patch fixes the path separator in BreakpointResolverFileLine::DeduceSourceMapping() and the Windows specific absolute path in the test in case of the Windows host.
2024-04-18[lldb][test] Correctly fix break at _dl_debug_state test on arm.Zequan Wu
If lldb finds the dynamic linker in the search path or if the binary is linked staticlly, it will fail at `lldbutil.run_break_set_by_symbol` because the breakpoint is resolved. Otherwise, it's not resolved at this point. But we don't care if it's resolved or not. This test cares about if the breakpoint is hit or not after launching. This changes the num_expected_locations to -2, which means don't assert on if this breakpoint resolved or not.
2024-04-18[lldb] Disable break at _dl_debug_state test on armZequan Wu
2024-04-17[lldb][DynamicLoader] Fix lldb unable to stop at _dl_debug_state if user set ↵Zequan Wu
it before the process launched. (#88792) If user sets a breakpoint at `_dl_debug_state` before the process launched, the breakpoint is not resolved yet. When lldb loads dynamic loader module, it's created with `Target::GetOrCreateModule` which notifies any pending breakpoint to resolve. However, the module's sections are not loaded at this time. They are loaded after returned from [Target::GetOrCreateModule](https://github.com/llvm/llvm-project/blob/0287a5cc4e2a5ded1ae2e4079f91052e6a6b8d9b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp#L574-L577). This change fixes it by manually resolving breakpoints after creating dynamic loader module.
2024-02-21[lldb][test] Modernize assertEqual(value, bool) (#82526)Jordan Rupprecht
Any time we see the pattern `assertEqual(value, bool)`, we can replace that with `assert<bool>(value)`. Likewise for `assertNotEqual`. Technically this relaxes the test a bit, as we may want to make sure `value` is either `True` or `False`, and not something that implicitly converts to a bool. For example, `assertEqual("foo", True)` will fail, but `assertTrue("foo")` will not. In most cases, this distinction is not important. There are two such places that this patch does **not** transform, since it seems intentional that we want the result to be a bool: * https://github.com/llvm/llvm-project/blob/5daf2001a1e4d71ce1273a1e7e31cf6e6ac37c10/lldb/test/API/python_api/sbstructureddata/TestStructuredDataAPI.py#L90 * https://github.com/llvm/llvm-project/blob/5daf2001a1e4d71ce1273a1e7e31cf6e6ac37c10/lldb/test/API/commands/settings/TestSettings.py#L940 Followup to 9c2468821ec51defd09c246fea4a47886fff8c01. I patched `teyit` with a `visit_assertEqual` node handler to generate this.
2024-02-21[lldb][test] Modernize asserts (#82503)Jordan Rupprecht
This uses [teyit](https://pypi.org/project/teyit/) to modernize asserts, as recommended by the [unittest release notes](https://docs.python.org/3.12/whatsnew/3.12.html#id3). For example, `assertTrue(a == b)` is replaced with `assertEqual(a, b)`. This produces better error messages, e.g. `error: unexpectedly found 1 and 2 to be different` instead of `error: False`.
2024-02-16[lldb] Replace assertEquals with assertEqual (NFC) (#82073)Jonas Devlieghere
assertEquals is a deprecated alias for assertEqual and has been removed in Python 3.12. This wasn't an issue previously because we used a vendored version of the unittest module. Now that we use the built-in version this gets updated together with the Python version used to run the test suite.
2023-05-25[NFC][Py Reformat] Reformat python files in lldbJonas Devlieghere
This is an ongoing series of commits that are reformatting our Python code. Reformatting is done with `black` (23.1.0). If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run `git checkout --ours <yourfile>` and then reformat it with black. RFC: https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style Differential revision: https://reviews.llvm.org/D151460
2023-03-03Add HitCount into Breakpoint statisticsJeffrey Tan
Turns out breakpoint statistics is missing hitCount. This patches adds the hitCount field. Differential Revision: https://reviews.llvm.org/D145203
2022-11-11[lldb] Rewrite to assertEqual/assertNotEqual (NFC)Dave Lee
Using the more specific assert* methods results in more useful error message.
2022-10-24Fix breakpoint setting so it always works when there is a line entry in a ↵Greg Clayton
compile unit's line table. Prior to this fix, if the compile unit function: void CompileUnit::ResolveSymbolContext(const SourceLocationSpec &src_location_spec, SymbolContextItem resolve_scope, SymbolContextList &sc_list); was called with a resolve scope that wasn't just eSymbolContextLineEntry, we would end up calling: line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope); This is ok as long as the line entry's base address is able to be resolved back to the same information, but there were problems when it didn't. The example I found was we have a file with a bad .debug_aranges section where the address to compile unit mapping was incomplete. When this happens, the above function call to calculate the symbol context would end up matching the module and it would NULL out the compile unit and line entry, which means we would fail to set this breakpoint. We have many other clients that ask for eSymbolContextEverything as the resolve_scope, so all other locations could end up failing as well. The solutions is to make sure the compile unit matches the current compile unit after calling the calculate symbol context. If the compile unit is NULL, then we report an error via the module/debugger as this indicates an entry in the line table fails to resolve back to any compile unit. If the compile unit is not NULL and it differs from the current compile unit, we restore the current compile unit and line entry to ensure the call to .CalculateSymbolContext doesn't match something completely different, as can easily happen if LTO or other link time optimizations are enabled that could end up outlining or merging functions. This patch allows breakpoint succeeding to work as expected and not get short circuited by our address lookup logic failing. Differential Revision: https://reviews.llvm.org/D136207
2022-09-22Add auto source map deduce count statisticsJeffrey Tan
This patch adds auto source map deduce count as a target level statistics. This will help telemetry to track how many debug sessions benefit from this feature. Differential Revision: https://reviews.llvm.org/D134483
2022-09-19Add auto deduce source map settingJeffrey Tan
This patch adds a new "target.auto-source-map-relative" setting. If enabled, this setting may auto deduce a source map entry based on requested breakpoint path and the original path stored in debug info for resolved breakpoint. As an example, if debug info contains "./a/b/c/main.cpp", user sets a source breakpoint at "/root/repo/x/y/z/a/b/c/main.cpp". The breakpoint will resolve correctly now with Greg's patch https://reviews.llvm.org/D130401. However, the resolved breakpoint will use "./a/b/c/main.cpp" to locate source file during stop event which would fail most of the time. With the new "target.auto-source-map-relative" setting enabled, a auto deduced source map entry "." => "/root/repo/x/y/z" will be added. This new mapping will help lldb to map resolved breakpoint path "./a/b/c/main.cpp" back to "/root/repo/x/y/z/a/b/c/main.cpp" and locate it on disk. If an existing source map entry is used the patch also concatenates the auto deduced entry with any stripped reverse mapping prefix (see example below). As a second example, debug info contains "./a/b/c/main.cpp" and user sets breakpoint at "/root/repo/x/y/z/a/b/c/main.cpp". Let's say there is an existing source map entry "." => "/root/repo"; this mapping would strip the prefix out of "/root/repo/x/y/z/a/b/c/main.cpp" and use "x/y/z/a/b/c/main.cpp" to resolve breakpoint. "target.auto-source-map-relative" setting would auto deduce a new potential mapping of "." => "x/y/z", then it detects that there is a stripped prefix from reverse mapping and concatenates it as the new mapping: "." => "/root/repo/x/y/z" which would correct map "./a/b/c/main.cpp" path to new path in disk. This patches depends on https://reviews.llvm.org/D130401 to use new added SBDebugger::GetSetting() API for testing. Differential Revision: https://reviews.llvm.org/D133042
2022-09-19[lldb] Reset breakpoint hit count before new runsFelipe de Azevedo Piovezan
A common debugging pattern is to set a breakpoint that only stops after a number of hits is recorded. The current implementation never resets the hit count of breakpoints; as such, if a user re-`run`s their program, the debugger will never stop on such a breakpoint again. This behavior is arguably undesirable, as it renders such breakpoints ineffective on all but the first run. This commit changes the implementation of the `Will{Launch, Attach}` methods so that they reset the _target's_ breakpoint hitcounts. Differential Revision: https://reviews.llvm.org/D133858
2022-08-15[LLDB] Remove __future__ imports from testsDavid Spickett
Not needed now that we require python 3. Reviewed By: kastiglione, JDevlieghere Differential Revision: https://reviews.llvm.org/D131761
2022-08-08Implement better path matching in FileSpecList::FindCompatibleIndex(...).Greg Clayton
Currently a FileSpecList::FindFileIndex(...) will only match the specified FileSpec if: - it has filename and directory and both match exactly - if has a filename only and any filename in the list matches Because of this, we modify our breakpoint resolving so it can handle relative paths by doing some extra code that removes the directory from the FileSpec when searching if the path is relative. This patch is intended to fix breakpoints so they work as users expect them to by adding the following features: - allow matches to relative paths in the file list to match as long as the relative path is at the end of the specified path at valid directory delimiters - allow matches to paths to match if the specified path is relative and shorter than the file paths in the list This allows us to remove the extra logic from BreakpointResolverFileLine.cpp that added support for setting breakpoints with relative paths. This means we can still set breakpoints with relative paths when the debug info contains full paths. We add the ability to set breakpoints with full paths when the debug info contains relative paths. Debug info contains "./a/b/c/main.cpp", the following will set breakpoints successfully: - /build/a/b/c/main.cpp - a/b/c/main.cpp - b/c/main.cpp - c/main.cpp - main.cpp - ./c/main.cpp - ./a/b/c/main.cpp - ./b/c/main.cpp - ./main.cpp This also ensures that we won't match partial directory names, if a relative path is in the list or is used for the match, things must match at the directory level. The breakpoint resolving code will now use the new FileSpecList::FindCompatibleIndex(...) function to allow this fuzzy matching to work for breakpoints. Differential Revision: https://reviews.llvm.org/D130401
2022-06-17[lldb][tests] Automatically call compute_mydir (NFC)Dave Lee
Eliminate boilerplate of having each test manually assign to `mydir` by calling `compute_mydir` in lldbtest.py. Differential Revision: https://reviews.llvm.org/D128077
2022-05-31Fix a copy-paste error in "br com add -s py -o 'some_python' BKPT_NAME"Jim Ingham
The function that was supposed to iterate over all the breakpoints sharing BKPT_NAME stopped after the first one because of a reversed "if success" condition. Differential Revision: https://reviews.llvm.org/D126730
2022-02-14[lldb] Replace asserts on .Success() with assertSuccess()Dave Lee
Replace forms of `assertTrue(err.Success())` with `assertSuccess(err)` (added in D82759). * `assertSuccess` prints out the error's message * `assertSuccess` expresses explicit higher level semantics, both to the reader and for test failure output * `assertSuccess` seems not to be well known, using it where possible will help spread knowledge * `assertSuccess` statements are more succinct Differential Revision: https://reviews.llvm.org/D119616
2021-11-17[lldb/test] Added lldbutil function to test a breakpointSYNOPSYS\georgiev
Testing the breakpoint itself rather than the lldb string. Differential Revision: https://reviews.llvm.org/D111899
2021-10-18Add tests for the other variants of BreakpointCreateBySourceRegex.Jim Ingham
I added some tests for the case where the breakpoints take immediately to the extant test case, and made a new test case for when the source regex breakpoint will be set in a dlopen-ed library. I also noticed when doing this that "lldbutil.run_to_source_breakpoint can't handle the case where the breakpoint will be in a dlopen-ed library, since it requires the breakpoint to have at least 1 location before run. I fixed that by adding a parameter to say whether a before run location is expected. Differential Revision: https://reviews.llvm.org/D111920
2021-09-30[lldb] Remove support for replaying the test suite from a reproducerJonas Devlieghere
This patch removes the infrastructure to replay the test suite from a reproducer, as well as the modifications made to the individual tests.
2021-07-29[source map] fix relative path breakpointsWalter Erquinigo
https://reviews.llvm.org/D45592 added a nice feature to be able to specify a breakpoint by a relative path. E.g. passing foo.cpp or bar/foo.cpp or zaz/bar/foo.cpp is fine. However, https://reviews.llvm.org/D68671 by mistake disabled the test that ensured this functionality works. With time, someone made a small mistake and fully broke the functionality. So, I'm making a very simple fix and the test passes. Differential Revision: https://reviews.llvm.org/D107126
2021-07-27Fix "break delete --disabled" with no arguments.Jim Ingham
The code that figured out which breakpoints to delete was supposed to set the result status if it found breakpoints, and then the code that actually deleted them checked that the result's status was set. The code for "break delete --disabled" failed to set the status if no "protected" breakpoints were provided. This was a confusing way to implement this, so I reworked it with early returns so it was less error prone, and added a test case for the no arguments case. Differential Revision: https://reviews.llvm.org/D106623
2021-05-24[lldb] Introduce createTestTarget for creating a valid target in API testsRaphael Isemann
At the moment nearly every test calls something similar to `self.dbg.CreateTarget(self.getBuildArtifact("a.out"))` and them sometimes checks if the created target is actually valid with something like `self.assertTrue(target.IsValid(), "some useless text")`. Beside being really verbose the error messages generated by this pattern are always just indicating that the target failed to be created but now why. This patch introduces a helper function `createTestTarget` to our Test class that creates the target with the much more verbose `CreateTarget` overload that gives us back an SBError (with a fancy error). If the target couldn't be created the function prints out the SBError that LLDB returned and asserts for us. It also defaults to the "a.out" build artifact path that nearly all tests are using to avoid to hardcode "a.out" in every test. I converted a bunch of tests to the new function but I'll do the rest of the test suite as follow ups. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D102771
2020-09-23Add `breakpoint delete --disabled`: deletes all disabled breakpoints.Jim Ingham
Differential Revision: https://reviews.llvm.org/D88129
2020-05-14[lldb/Test] Skip remaining 'side_effect' tests with reproducers.Jonas Devlieghere
The side_effect Python package bypasses the reproducer instrumentation and therefore these tests are not expected to replay from a reproducer.
2020-04-21[lldb/Test] Add skipIfReproducer for tests that are not expected to workJonas Devlieghere
Some tests are not expected to work with reproducers, for example tests that completely circumvent the reproducers (i.e. using the side_effects Python module) or that rely on changes to the file system.
2020-02-20[lldb] Remove license headers from all test source filesRaphael Isemann
Summary: Around a third of our test sources have LLVM license headers. This patch removes those headers from all test sources and also fixes any tests that depended on the length of the license header. The reasons for this are: * A few tests verify line numbers and will start failing if the number of lines in the LLVM license header changes. Once I landed my patch for valid SourceLocations in debug info we will probably have even more tests that verify line numbers. * No other LLVM project is putting license headers in its test files to my knowledge. * They make the test sources much more verbose than they have to be. Several tests have longer license headers than the actual test source. For the record, the following tests had their line numbers changed to pass with the removal of the license header: lldb-api :: functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py lldb-shell :: Reproducer/TestGDBRemoteRepro.test lldb-shell :: Reproducer/TestMultipleTargets.test lldb-shell :: Reproducer/TestReuseDirectory.test lldb-shell :: ExecControl/StopHook/stop-hook-threads.test lldb-shell :: ExecControl/StopHook/stop-hook.test lldb-api :: lang/objc/exceptions/TestObjCExceptions.py Reviewers: #lldb, espindola, JDevlieghere Reviewed By: #lldb, JDevlieghere Subscribers: emaste, aprantl, arphaman, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D74839
2020-02-11[lldb][test] Remove symlink for API tests.Jordan Rupprecht
Summary: Moves lldbsuite tests to lldb/test/API. This is a largely mechanical change, moved with the following steps: ``` rm lldb/test/API/testcases mkdir -p lldb/test/API/{test_runner/test,tools/lldb-{server,vscode}} mv lldb/packages/Python/lldbsuite/test/test_runner/test lldb/test/API/test_runner for d in $(find lldb/packages/Python/lldbsuite/test/* -maxdepth 0 -type d | egrep -v "make|plugins|test_runner|tools"); do mv $d lldb/test/API; done for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-vscode -maxdepth 1 -mindepth 1 | grep -v ".py"); do mv $d lldb/test/API/tools/lldb-vscode; done for d in $(find lldb/packages/Python/lldbsuite/test/tools/lldb-server -maxdepth 1 -mindepth 1 | egrep -v "gdbremote_testcase.py|lldbgdbserverutils.py|socket_packet_pump.py"); do mv $d lldb/test/API/tools/lldb-server; done ``` lldb/packages/Python/lldbsuite/__init__.py and lldb/test/API/lit.cfg.py were also updated with the new directory structure. Reviewers: labath, JDevlieghere Tags: #lldb Differential Revision: https://reviews.llvm.org/D71151