Commit graph

1945 commits

Author SHA1 Message Date
Karthik Nadig
6e44d161ca
Fix for attach to pid tests (#1747)
* Fix for attach to pid tests

* Address comments.

* More asserts and comments.
2019-09-05 18:12:22 -07:00
Fabio Zadrozny
90298c4e79 Password no longer echoed in getpass (in Windows). Fixes #1723 2019-08-30 08:04:27 -03:00
Fabio Zadrozny
f45444f9f9 Make it possible to evaluate without a frameId. Fixes #1716 2019-08-30 08:01:54 -03:00
Karthik Nadig
2a367b2f4b
Bunch of minor test fixes (#1726)
* Bunch of minor test fixes

* Fix linter and multiproc

* Remove missed os.environ

* Rename and move stop_debugging

* Add evaluate helper

* Add exit_code property

* Enable pytest and flake8 in workspace

* Fix test failure

* Set ptvsd python path in tests

* Rename exit_code to expected_exit_code
2019-08-29 00:19:50 -07:00
Fabio Zadrozny
20d0f1a0bc Add processId to initialize response. Fixes #1717 2019-08-28 07:43:17 -03:00
Fabio Zadrozny
816ccb631b Provide access tokens in debugger. Fixes #1710 2019-08-28 07:43:17 -03:00
Pavel Minaev
5f2cb304a6 Use pydevd.settrace() argument instead of patch_new_process_functions() to enable multiprocessing.
Add multiprocessing= argument to attach() and enable_attach().

Refactor common code in attach() and enable_attach().

Remove broken legacy multiproc implementation.
2019-08-24 15:38:48 -07:00
Pavel Minaev
915515d910 Fix output capture for "noDebug".
Ensure that all captured output is reported to the IDE before reporting process exit.

Correctly report "process", "exited", and "terminated" events for "noDebug".

Don't treat partial message reads as fatal error.

Switch test_nodebug to "internalConsole", so that it can properly produce "output" events.

Expect failure response from "setBreakpoints" in test_nodebug.

Fix environment dict being shared between subsequent test runs, causing spurious enable_attach() in debuggee.

Fix ordering in debuggee and adapter cleanup in debug.Session.

Fix launcher.py on Python 2.7
2019-08-24 15:38:48 -07:00
Karthik Nadig
3158583bd3
Fix some tests. (#1719)
* Don't wait for thread event

* Fix get variables

* Fix completion tests

* Fix evaluate tests

* Fix linter
2019-08-23 10:28:46 -07:00
Karthik Nadig
2afcdc91f5
Minor fixes (#1718)
* Fix missed return

* Remove threading check
2019-08-22 17:39:35 -07:00
Fabio Zadrozny
15a9befccf
Merge master > dbg_adapter_refactor (#1709) 2019-08-22 08:55:01 -03:00
Fabio Zadrozny
a08708dc8b
Autoreload in CherryPy no longer blocked by pydevd threads. Fixes #1691 (#1702)
* Autoreload in CherryPy no longer blocked by pydevd threads. Fixes #1691

* Don't send CMD_EXIT to the IDE.
2019-08-20 14:42:15 -03:00
Karthik Nadig
9ece432dff
Attach to pid support (#1701)
* Fix launcher test

* Attach to pid support

* Address comments.

* Minor tweaks
2019-08-19 14:08:23 -07:00
Pavel Minaev
e94980f86c Do not load ptvsd.server (and hence, pydevd) unless the subpackage is loaded explicitly or via a public API entrypoint that requires it.
Move docstrings to top-level package, and update them to reflect the current behavior.

Remove unused code in ptvsd.common.log.

Move sys.path/prefix/site_packages logging into ptvsd.common.log, and log it from adapter and server to the same level of detail as the tests.

Fix injected code snipped for attach-by-PID.

Fix some Unicode issues in adapter and tests.

Refactor Timeline, debug.Session, and start methods.
2019-08-18 11:43:23 -07:00
Karthik Nadig
6eb65d8a7e
Support for noDebug (#1696)
* noDebug mode support

* Ensure we get the debuggee pid on launch

* Fix state change bug

* Tweaking pid retreival

* Use makefile and simplify pid retreival

* Addressing comments

* Run formatter

* Change name common.socket to common.sockets

* Add some timeouts

* Fix linter
2019-08-17 20:23:06 -07:00
Pavel Minaev
99c0a5d82d Fix #1697: Adapter doesn't handle "env" properly in "internalConsole" mode on Python 2.7
Encode environment variables on Python 2.

Fix #1659: Debuggee output breaks adapter with "internalConsole"

Use os.devnull for debuggee stdin, and redirect debuggee stdout to stderr.

Capture output for debuggee stdout and stderr, generate DAP "output" events from it, and suppress the same coming from the debug server.
2019-08-16 22:26:12 -07:00
Karthik Nadig
2781f712a2
Fix windows build path 2019-08-14 01:27:02 -07:00
Karthik Nadig
2cfdd9d1cf
Fix root path 2019-08-14 01:19:57 -07:00
Fabio Zadrozny
46e1b758bc Only set PyDB as the global debugger after it's initialized. Fixes #1688 (#1690) 2019-08-13 11:42:18 -07:00
Pavel Minaev
9f37496b4c Fix parsing "host" and "post" in "attach" request. 2019-08-12 14:48:01 -07:00
Pavel Minaev
c5feeea05b Fix ptvsd.server command line parsing for filenames on Python 2. 2019-08-12 14:44:44 -07:00
Pavel Minaev
a698340985 Add .cmd script to clean various Python-related build and run artifacts in the repo - .pyc, .pyo, .pyd, __pycache__. 2019-08-12 14:14:39 -07:00
Karthik Nadig
0f6a9bb1d6
Update tests to use python debug adapter (#1660)
* Initial fix for launch

* Minor fixes

* Succesful launch tests

* More launch test fixes

* Some bit of cleanup

* Fix linter

* More cleanup

* Attach using import

*  Fix circular importing

* Support attach via command line

* Backchannel and Other test fixes

* Linter fix

* Python path fix in test

* Fix lint after rebase

* Support exitCode in tests

* More fixes after rebase

* Fix expected exit code

* Remove changes to MessageDict __call__

* Remove hold subprocess event
2019-08-12 13:53:24 -07:00
Pavel Minaev
981b1d1559 Fix #1648: Messaging does not allow reverse requests
Separate message parsing and message handling into separate threads.

Remove nested message handling in request handlers via `yield`, since it is incompatible with the new split model, and replace it with NO_RESPONSE and Request.respond() to defer responses until later.

Change Message.cant_handle() and Message.isnt_valid() to respond to the request and return the exception, instead of raising it, to accommodate NO_RESPONSE scenarios where a failure needs to be reported later.

Fix #1678: Do not rely on "processId" being returned by "runInTerminal" request

Extract debuggee PID from the "process" event sent by the debug server.

Fix #1679: "exited" event sometimes reports "exitCode": null

Report it as -1 if it cannot be retrieved from the debuggee process.

Fix #1680: Fatal errors in message loop do not fail fast

os._exit() immediately if a fatal error occurs in message parsing or message handling background threads.
2019-08-11 19:46:54 -07:00
Pavel Minaev
7256e99b52 Use a separate exception type NoMoreMessages to indicate end-of-stream for JSON messaging, to avoid leaking EOFError from disk I/O or from another stream not being properly reported as errors. 2019-08-11 19:46:54 -07:00
Karthik Nadig
b61c05a3e5
Set don't trace patterns from the debug server (#1676) 2019-08-09 15:55:35 -07:00
Fabio Zadrozny
152edebd4e Different implementation to set tracing to other threads for Python 3.7. Fixes #1587 (#1669) 2019-08-09 10:36:34 -07:00
Karthik Nadig
81ac055f3f
Ensure stopped on goto changes focus (#1668)
* Ensure stopped on goto changes focus

* Test fix
2019-08-08 17:27:34 -07:00
Karthik Nadig
84cac1499e
Cancel wait for attach if IDE is disconnected (#1657)
* Cancel wait for attach if IDE is disconnected

* Remove cancel wait wrapper

* cleanup
2019-08-05 16:17:58 -07:00
Karthik Nadig
ebf4629ca8
Add --log-dir switch to adapter (#1653)
* Add --log-dir switch to adapter

* Address comments
2019-08-02 19:30:40 -07:00
Karthik Nadig
e093c86fba
#1449, #1498, partially #1448 (#1651)
* Remove wrapper and in-proc support code

* Fixing up multiproc patching

* Address comments

* Import cleanup

* More cleanup

* Remove loopback fast path

* Disable IDE disconnect unpause-ing

* Add missing file to do not trace
2019-08-02 13:08:07 -07:00
Pavel Minaev
0ea50467aa Fix #1488: Handling launch (spawn ptvsd) (#1647)
Fix #1605: Debuggee process lifetime management
Mitigate #1637: log.exception() doesn't capture the full stack

Handle "launch" request, parse and validate the debug configuration, and spawn the debuggee process with debug server.

Track debuggee process and its subprocesses, and kill them as needed.

Refactor Singleton and ThreadSafeSingleton to allow for easier synchronization between IDE and server message handlers without excessive locking.

Fix various corner cases and race conditions in disconnect scenarios.

Make log.exception() log the calling stack, not just the exception stack.

Add JSON property validation to MessageDict.

Add --log-stderr switch to the server to enable full logging to stderr.

Add --cls switch to the adapter to reset terminal before logging anything (for convenience when debugging it).

Add some printf-debugging helpers.
2019-07-31 13:05:06 -07:00
Karthik Nadig
f6d04ea0c7
Create question.md 2019-07-30 18:34:17 -07:00
Karthik Nadig
7ceda11fc4
Update contributing instructions 2019-07-26 00:12:04 -07:00
Karthik Nadig
4581c52de7
Add initialize request (#1618) 2019-07-23 13:29:25 -07:00
Pavel Minaev
527a17cdce Fix #1614: Test run times out on Python 2.7 (#1615)
Close the watchdog message channel from the test process side after "stop" command is sent and acknowledged.
2019-07-22 22:21:01 -07:00
Pavel Minaev
bb7375da31 Fix test_launcher on Python 2.7. 2019-07-22 17:01:53 -07:00
Pavel Minaev
061f5e9721 Fix linting issues. 2019-07-22 17:01:53 -07:00
Pavel Minaev
e0ee0bde53 Add CODEOWNERS. 2019-07-22 17:01:53 -07:00
Pavel Minaev
6727665878 Fix #1612: Parse and expose DAP capabilities
Add ptvsd.adapter.contract module as a single access point for capabilities and other immutable IDE and server metadata.

Change the semantics of Channels.server() to enable checks for disconnected server.

Fix "disconnect" and "terminate" handling when not connected to debug server.

Do best-effort handling of "ptvsd_systemInfo" if not connected to debug server.
2019-07-22 17:01:53 -07:00
Pavel Minaev
b08e8e2233 Fix Message.is_response() 2019-07-22 17:01:53 -07:00
Pavel Minaev
e87025d664 Provide backwards compatibility with "from ptvsd.__main__ import main". 2019-07-22 17:01:53 -07:00
Pavel Minaev
b2d5414d0e Reformat code. 2019-07-22 17:01:53 -07:00
Pavel Minaev
5c6f3779d3 Add Message.request() helper for synchronous requests that wait for response.
Add Message.is_response() helper.

Add Message.payload helper accessor that redirects to Message.arguments or Message.body as appropriate.
2019-07-22 17:01:53 -07:00
Pavel Minaev
ffbbf64832 Add docstring to ptvsd.adapter.options 2019-07-22 17:01:53 -07:00
Pavel Minaev
7973e5beac Fix sys.path patching when running ptvsd without -m. 2019-07-22 17:01:53 -07:00
Karthik Nadig
6aa8134125
Add launcher script that handles wait-on-* feature (#1609)
* Add launcher script that handles wait-on-* feature

* Address comments

* Improve argument parsing

* Add tests

* Address test comments
2019-07-19 13:51:51 -07:00
Karthik Nadig
d50e63eaa7
Move debugger attached state into pydevd (#1610)
* Move debugger attached state into pydevd

* Fix linter

* Fix tests
2019-07-19 13:50:38 -07:00
Pavel Minaev
907351522d Fix race condition in test_attach. 2019-07-18 10:13:02 -07:00
Pavel Minaev
73d29fa55b Work around #1603 in tests.
Add long_tmpdir fixture, that always supplies a long rather than short path name on Windows.

Use long_tmpdir in the implementation of @pyfile, and in all tests that use tmpdir to generate code.
2019-07-18 10:13:02 -07:00