summaryrefslogtreecommitdiff
path: root/lldb/test/API/iohandler
AgeCommit message (Collapse)Author
2025-05-27[lldb][NFC] update API tests which skip/expect-fail armJason Molenda
The architectures provided to skipIf / expectedFail are regular expressions (v. _match_decorator_property() in decorators.py so on Darwin systems "arm64" would match the skips for "arm" (32-bit Linux). Update these to "arm$" to prevent this, and also update three tests (TestBuiltinFormats.py, TestCrossDSOTailCalls.py, TestCrossObjectTailCalls.py) that were skipped for arm64 via this behavior, and need to be skipped or they will fail. This was moviated by the new TestDynamicValue.py test which has an expected-fail for arm, but the test was passing on arm64 Darwin resulting in failure for the CIs.
2025-05-13[lldb] Move lldb_enable_attach from test_common to a separate header (#139550)Pavel Labath
test_common is force-included into every compilation, which causes problems when we're compiling assembly code, as we were in #138805. This avoids that as we can include the header only when it's needed.
2025-03-19[lldb] Require wide char support in unicode test (#131951)David Peixotto
The unicode test sends some unicode input to lldb through pexpect and expects the output to be echoed back in an error message. This only works correctly when editline was compiled with wide character support. This commit modifies the test to require the necessary libedit configuration.
2025-02-28[lldb] fix(lldb/**.py): fix invalid escape sequences (#94034)Eisuke Kawashima
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2024-12-16[lldb] Disable TestIOHandlerResizeNoEditline.py for Windows hosts (#120025)Dmitry Vasilyev
See #120021 for details.
2024-05-15[lldb][Windows] Fixed the TestIOHandlerResizeNoEditline test (#92286)Dmitry Vasilyev
This test caused python crash on Windows x86_64 host with the exit code 0xC0000409 (STATUS_STACK_BUFFER_OVERRUN). Close the input stream before exit to avoid this crash.
2024-04-29Skip various tests under ASAN on green dragon (#90531)Adrian Prantl
using the macOS version as a proxy. I can't reproduce any of these failures locally, but the tests all use pexpect and probably have bad timeout behavior under high load.
2023-09-27Fix a bug in handling ^C at the "y/n/a" completion prompt.Jim Ingham
We just forget to check for interrupt while waiting for the answer to the prompt. But if we are in the interrupt state then the lower layers of the EditLine code just eat all characters so we never get out of the query prompt. You're pretty much stuck and have to kill lldb. The solution is to check for the interrupt. The patch is a little bigger because where I needed to check the Interrupt state I only had the ::EditLine object, but the editor state is held in lldb's EditLine wrapper, so I had to do a little work to get my hands on it.
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
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-18[lldb/test] Fix failures caused by a previous PExpect.launch changeMed Ismail Bennani
This should fix the issues introduced by d71d1a9, which skipped all the test setup commands. This also fixes the test failures happening in TestAutosuggestion.py. Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-05-18Revert "[lldb/test] Make some tests as XFAIL while I investigate the issue"Med Ismail Bennani
This reverts commit 80589f272c200798b57a5151680a993bc2cc00a7.
2022-05-18[lldb/test] Make some tests as XFAIL while I investigate the issueMed Ismail Bennani
This is very likely to be caused by d71d1a947bee1247e952f22c13ad3ed3d041e36a. Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-04-08Skip test on earlier clang versionsAdrian Prantl
2022-03-28[LLDB] Skip TestProcessIOHandlerInterrupt Arm/AArch64 LinuxMuhammad Omair Javaid
This patch skips TestProcessIOHandlerInterrupt on Arm/AArch64. PExpect tests are not stable when run in containerized machine.
2022-03-18[lldb] Increase timeout in TestProcessIOHandlerInterruptPavel Labath
The small value was not meant to be checked in.
2022-03-18[lldb] Fix TestProcessIOHandlerInterrupt.py for macosPavel Labath
On darwin, we don't completely suppress the signal used to interrupt the inferior. The underlying read syscall returns EINTR, which causes premature termination of the input loop. Work around that by hand-rolling an EINTR-resistant version of getline.
2022-03-18[lldb] Fix ^C handling in IOHandlerProcessSTDIOPavel Labath
D120762 accidentally moved the interrupt check into the block which was reading stdio. This meant that a ^C only took effect after a regular character has been pressed. This patch fixes that and adds a (pexpect) test. Differential Revision: https://reviews.llvm.org/D121912
2022-03-08[LLDB] Skip TestIOHandlerProcessSTDIO.py for Arm/AArch64 LinuxMuhammad Omair Javaid
This patch disables TestIOHandlerProcessSTDIO.py for Arm/AArch64 Linux to silence random test failures on buildbots. IO handler tests are known to randomly fail on arm/aarch64 linux buildbots due to pexpect timeouts.
2022-03-07[lldb] Add a setting to change the autosuggestion ANSI escape codesJonas Devlieghere
I'm a big fan of the autosuggestion feature but my terminal/color scheme doesn't display faint any differently than regular lldb output, which makes the feature a little confusing. This patch add a setting to change the autosuggestion ANSI escape codes. For example, to display the autosuggestion in italic, you can add this to your ~/.lldbinit settings set show-autosuggestion-ansi-prefix ${ansi.italic} setting set show-autosuggestion-ansi-suffix ${ansi.normal} Differential revision: https://reviews.llvm.org/D121064
2022-03-02[lldb] Skip check for the lldb prompt in TestIOHandlerProcessSTDIOJonas Devlieghere
The check for the prompt isn't essential for this test. The check fail on the lldb-arm-ubuntu because of what appears to be a missing space after the prompt. Rather than disabling the test, let's see if we can get it to pass without it.
2022-03-02[lldb] Avoid data race in IOHandlerProcessSTDIOJonas Devlieghere
This patch fixes a data race in IOHandlerProcessSTDIO. The race is happens between the main thread and the event handling thread. The main thread is running the IOHandler (IOHandlerProcessSTDIO::Run()) when an event comes in that makes us pop the process IO handler which involves cancelling the IOHandler (IOHandlerProcessSTDIO::Cancel). The latter calls SetIsDone(true) which modifies m_is_done. At the same time, we have the main thread reading the variable through GetIsDone(). This patch avoids the race by using a mutex to synchronize the two threads. On the event thread, in IOHandlerProcessSTDIO ::Cancel method, we obtain the lock before changing the value of m_is_done. On the main thread, in IOHandlerProcessSTDIO::Run(), we obtain the lock before reading the value of m_is_done. Additionally, we delay calling SetIsDone until after the loop exists, to avoid a potential race between the two writes. Write of size 1 at 0x00010b66bb68 by thread T7 (mutexes: write M2862, write M718324145051843688): #0 lldb_private::IOHandler::SetIsDone(bool) IOHandler.h:90 (liblldb.15.0.0git.dylib:arm64+0x971d84) #1 IOHandlerProcessSTDIO::Cancel() Process.cpp:4382 (liblldb.15.0.0git.dylib:arm64+0x5ddfec) #2 lldb_private::Debugger::PopIOHandler(std::__1::shared_ptr<lldb_private::IOHandler> const&) Debugger.cpp:1156 (liblldb.15.0.0git.dylib:arm64+0x3cb2a8) #3 lldb_private::Debugger::RemoveIOHandler(std::__1::shared_ptr<lldb_private::IOHandler> const&) Debugger.cpp:1063 (liblldb.15.0.0git.dylib:arm64+0x3cbd2c) #4 lldb_private::Process::PopProcessIOHandler() Process.cpp:4487 (liblldb.15.0.0git.dylib:arm64+0x5c583c) #5 lldb_private::Debugger::HandleProcessEvent(std::__1::shared_ptr<lldb_private::Event> const&) Debugger.cpp:1549 (liblldb.15.0.0git.dylib:arm64+0x3ceabc) #6 lldb_private::Debugger::DefaultEventHandler() Debugger.cpp:1622 (liblldb.15.0.0git.dylib:arm64+0x3cf2c0) #7 std::__1::__function::__func<lldb_private::Debugger::StartEventHandlerThread()::$_2, std::__1::allocator<lldb_private::Debugger::StartEventHandlerThread()::$_2>, void* ()>::operator()() function.h:352 (liblldb.15.0.0git.dylib:arm64+0x3d1bd8) #8 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) HostNativeThreadBase.cpp:62 (liblldb.15.0.0git.dylib:arm64+0x4c71ac) #9 lldb_private::HostThreadMacOSX::ThreadCreateTrampoline(void*) HostThreadMacOSX.mm:18 (liblldb.15.0.0git.dylib:arm64+0x29ef544) Previous read of size 1 at 0x00010b66bb68 by main thread: #0 lldb_private::IOHandler::GetIsDone() IOHandler.h:92 (liblldb.15.0.0git.dylib:arm64+0x971db8) #1 IOHandlerProcessSTDIO::Run() Process.cpp:4339 (liblldb.15.0.0git.dylib:arm64+0x5ddc7c) #2 lldb_private::Debugger::RunIOHandlers() Debugger.cpp:982 (liblldb.15.0.0git.dylib:arm64+0x3cb48c) #3 lldb_private::CommandInterpreter::RunCommandInterpreter(lldb_private::CommandInterpreterRunOptions&) CommandInterpreter.cpp:3298 (liblldb.15.0.0git.dylib:arm64+0x506478) #4 lldb::SBDebugger::RunCommandInterpreter(bool, bool) SBDebugger.cpp:1166 (liblldb.15.0.0git.dylib:arm64+0x53604) #5 Driver::MainLoop() Driver.cpp:634 (lldb:arm64+0x100006294) #6 main Driver.cpp:853 (lldb:arm64+0x100007344) Differential revision: https://reviews.llvm.org/D120762
2022-02-14[lldb] Skip TestIOHandlerPythonREPLSigint if *host* is linuxJonas Devlieghere
The current dectorator (@skipIfLinux) will skip the test if the lldb platform is the linux platform, but the issue is with the OS that lldb is running on, not the OS that lldb is debugging. Update the decorator to skip the test if the host is Linux. Thank you Ted Woodward for pointing this out.
2022-01-15[LLDB] Skip TestIOHandlerPythonREPLSigint.py on AArch64/LinuxMuhammad Omair Javaid
TestIOHandlerPythonREPLSigint.py is running falky on AArch64/Linux buildbot failing randomly. Skipping it for AArch64/Linux as well.
2022-01-14[LLDB] Skip TestIOHandlerPythonREPLSigint.py on Arm/LinuxMuhammad Omair Javaid
TestIOHandlerPythonREPLSigint.py is failing on Arm/Linux buildbot. I am marking it as skip for now.
2022-01-13[lldb] Fix that the embedded Python REPL crashes if it receives SIGINTJonas Devlieghere
When LLDB receives a SIGINT while running the embedded Python REPL it currently just crashes in ScriptInterpreterPythonImpl::Interrupt with an error such as the one below: Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL) The faulty code that causes this error is this part of ScriptInterpreterPythonImpl::Interrupt: PyThreadState *state = PyThreadState_GET(); if (!state) state = GetThreadState(); if (state) { long tid = state->thread_id; PyThreadState_Swap(state); int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt); The obvious fix I tried is to just acquire the GIL before this code is running which fixes the crash but the KeyboardInterrupt we want to raise immediately is actually just queued and would only be raised once the next line of input has been parsed (which e.g. won't interrupt Python code that is currently waiting on a timer or IO from what I can see). Also none of the functions we call here is marked as safe to be called from a signal handler from what I can see, so we might still end up crashing here with some bad timing. Python 3.2 introduced PyErr_SetInterrupt to solve this and the function takes care of all the details and avoids doing anything that isn't safe to do inside a signal handler. The only thing we need to do is to manually setup our own fake SIGINT handler that behaves the same way as the standalone Python REPL signal handler (which raises a KeyboardInterrupt). From what I understand the old code used to work with Python 2 so I kept the old code around until we officially drop support for Python 2. There is a small gap here with Python 3.0->3.1 where we might still be crashing, but those versions have reached their EOL more than a decade ago so I think we don't need to bother about them. Differential revision: https://reviews.llvm.org/D104886
2021-11-13Revert "[lldb] Fix that the embedded Python REPL crashes if it receives SIGINT"Raphael Isemann
This reverts commit cef1e07cc6d00b5b429d77133201e1f404a8023c. It broke the windows bot.
2021-11-12[lldb] Fix that the embedded Python REPL crashes if it receives SIGINTRaphael Isemann
When LLDB receives a SIGINT while running the embedded Python REPL it currently just crashes in `ScriptInterpreterPythonImpl::Interrupt` with an error such as the one below: ``` Fatal Python error: PyThreadState_Get: the function must be called with the GIL held, but the GIL is released (the current Python thread state is NULL) ``` The faulty code that causes this error is this part of `ScriptInterpreterPythonImpl::Interrupt`: ``` PyThreadState *state = PyThreadState_GET(); if (!state) state = GetThreadState(); if (state) { long tid = state->thread_id; PyThreadState_Swap(state); int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt); ``` The obvious fix I tried is to just acquire the GIL before this code is running which fixes the crash but the `KeyboardInterrupt` we want to raise immediately is actually just queued and would only be raised once the next line of input has been parsed (which e.g. won't interrupt Python code that is currently waiting on a timer or IO from what I can see). Also none of the functions we call here is marked as safe to be called from a signal handler from what I can see, so we might still end up crashing here with some bad timing. Python 3.2 introduced `PyErr_SetInterrupt` to solve this and the function takes care of all the details and avoids doing anything that isn't safe to do inside a signal handler. The only thing we need to do is to manually setup our own fake SIGINT handler that behaves the same way as the standalone Python REPL signal handler (which raises a KeyboardInterrupt). From what I understand the old code used to work with Python 2 so I kept the old code around until we officially drop support for Python 2. There is a small gap here with Python 3.0->3.1 where we might still be crashing, but those versions have reached their EOL more than a decade ago so I think we don't need to bother about them. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D104886
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-08-30[LLDB] Fix 'std::out_of_range' crashing bug when file name completion using ↵Hiroki
file path. When I run a lldb command that uses filename completion, if I enter a string that is not only a filename but also a string with a non-file name string added, such as "./" that is relative path string , it will crash as soon as I press the [Tab] key. For example, debugging an executable file named "hello" that is compiled from a file named "hello.c" , and I’ll put a breakpoint on line 3 of hello.c. ``` $ lldb ./hello (lldb) breakpoint set --file hello.c --line 3 ``` This is not a problem, but if I set "--file ./hello." and then press [Tab] key to complete file name, lldb crashes. ``` $ lldb ./hello (lldb) breakpoint set --file ./hello.terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr: __pos (which is 8) > this->size() (which is 7) ``` The crash was caused because substr() (in lldb/source/Host/common/Editline.cpp) cut out string which size is user's input string from the completion string. I modified the code that erase the user's intput string from current line and then add the completion string. Differential Revision: https://reviews.llvm.org/D108817
2021-08-09[LLDB] Skip random fails on Arm/AArch64 Linux buildbotMuhammad Omair Javaid
Following tests fail on Arm/AArch64 randomly with timeouts: TestMultilineNavigation.py TestBatchMode.py TestUnicode.py TestGdbRemote_vContThreads.py I am marking them as skipped until we find a away make to pass reliably.
2021-08-04[LLDB] Skip flaky tests on Arm/AArch64 Linux botsMuhammad Omair Javaid
Following LLDB tests fail randomly on LLDB Arm/AArch64 Linux buildbots. We still not have a reliable solution for these tests to pass consistently. I am marking them skipped for now. TestBreakpointCallbackCommandSource.py TestIOHandlerResize.py TestEditline.py TestGuiViewLarge.py TestGuiExpandThreadsTree.py TestGuiBreakpoints.py
2021-08-02[LLDB] Skip random failing tests on Arm/AArch64 Linux botsMuhammad Omair Javaid
Following tests have been failing randomly on LLDB Arm and AArch64 Linux builtbots: TestMultilineNavigation.py TestMultilineCompletion.py TestIOHandlerCompletion.py TestGuiBasic.py I have increased allocated CPU resources to these bots but it has not improved situation to an acceptable level. This patch marks them as skipped on Arm/AArch64 for now.
2021-03-10[lldb] [test] Update XFAILs for FreeBSD/aarch64Michał Górny
2020-08-14[lldb] Display autosuggestion part in gray if there is one possible suggestionShu Anzai
This is relanding D81001. The patch originally failed as on newer editline versions it seems CC_REFRESH will move the cursor to the start of the line via \r and then back to the original position. On older editline versions like the one used by default on macOS, CC_REFRESH doesn't move the cursor at all. As the patch changed the way we handle tab completion (previously we did REDISPLAY but now we're doing CC_REFRESH), this caused a few completion tests to receive this unexpected cursor movement in the output stream. This patch updates those tests to also accept output that contains the specific cursor movement commands (\r and then \x1b[XC). lldbpexpect.py received an utility method for generating the cursor movement escape sequence. Original summary: I implemented autosuggestion if there is one possible suggestion. I set the keybinds for every character. When a character is typed, Editline::TypedCharacter is called. Then, autosuggestion part is displayed in gray, and you can actually input by typing C-k. Editline::Autosuggest is a function for finding completion, and it is like Editline::TabCommand now, but I will add more features to it. Testing does not work well in my environment, so I can't confirm that it goes well, sorry. I am dealing with it now. Reviewed By: teemperor, JDevlieghere, #lldb Differential Revision: https://reviews.llvm.org/D81001
2020-08-12Revert "[lldb] Display autosuggestion part in gray if there is one possible ↵Raphael Isemann
suggestion" This reverts commit 246afe0cd17fce935a01171f3cca548e02523e5c. This broke the following tests on Linux it seems: lldb-api :: commands/expression/multiline-completion/TestMultilineCompletion.py lldb-api :: iohandler/completion/TestIOHandlerCompletion.py
2020-08-12[lldb] Display autosuggestion part in gray if there is one possible suggestionShu Anzai
I implemented autosuggestion if there is one possible suggestion. I set the keybinds for every character. When a character is typed, Editline::TypedCharacter is called. Then, autosuggestion part is displayed in gray, and you can actually input by typing C-k. Editline::Autosuggest is a function for finding completion, and it is like Editline::TabCommand now, but I will add more features to it. Testing does not work well in my environment, so I can't confirm that it goes well, sorry. I am dealing with it now. Reviewed By: teemperor, JDevlieghere, #lldb Differential Revision: https://reviews.llvm.org/D81001
2020-07-08[lldb] Skip TestIOHandlerResizeNoEditline on WindowsRaphael Isemann
It seems opening the empty file and trying use that file object as an input stream doesn't work on Windows. Skipping it for now.
2020-07-07[lldb] Make TestIOHandlerResizeNoEditline pass with Python 2Raphael Isemann
io.BytesIO seems to produce a stream in Python 2 which isn't recognized as a file object in the SWIG API, so this test fails for Python 2 (and I assume also an old SWIG version needs to be involved). Instead just open an empty input file which is a file object in all Python versions to make this test pass everywhere.
2020-06-30[lldb/Test] Skip TestIOHandlerResizeNoEditline with reproducersJonas Devlieghere
2020-06-19[lldb] Fix that SIGWINCH crashes IOHandlerEditline when we are not using the ↵Raphael Isemann
editline backend Summary: TerminalSizeChanged is called from our SIGWINCH signal handler but the IOHandlerEditline currently doesn't check if we are actually using the real editline backend. If we're not using the real editline backend, `m_editline_up` won't be set and `IOHandlerEditline::TerminalSizeChanged` will access the empty unique_ptr. In a real use case we don't use the editline backend when we for example read input from a file. We also create some temporary IOHandlerEditline's during LLDB startup it seems that are also treated as non-interactive (apparently to read startup commands). This patch just adds a nullptr check for`m_editline_up` as we do in the rest of IOHandlerEditline. Fixes rdar://problem/63921950 Reviewers: labath, friss Reviewed By: friss Subscribers: abidh, JDevlieghere Differential Revision: https://reviews.llvm.org/D81729
2020-05-12[lldb/Driver] Support terminal resizingFred Riss
Summary: The comment in the Editine.h header made it sound like editline was just unable to handle terminal resizing. We were not ever telling editline that the terminal had changed size, which might explain why it wasn't working. This patch threads a `TerminalSizeChanged()` callback through the IOHandler and invokes it from the SIGWINCH handler in the driver. Our `Editline` class already had a `TerminalSizeChanged()` method which was invoked only when editline was configured. This patch also changes `Editline` to not apply the changes right away in `TerminalSizeChanged()`, but instead defer that to the next character read. During my testing, it happened once that the signal was received while our `ConnectionFileDescriptor::Read` was allocating memory. As `el_resize` seems to allocate memory too, this crashed. Reviewers: labath, teemperor Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D79654
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