mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-17447 New command CMD_PROCESS_CREATED added to notify IDE that new subprocess is created
This commit is contained in:
@@ -55,6 +55,11 @@ def _on_forked_process():
|
||||
pydevd.threadingCurrentThread().__pydevd_main_thread = True
|
||||
pydevd.settrace_forked()
|
||||
|
||||
def _notify_process_created(dbg):
|
||||
if dbg is not None:
|
||||
cmd = dbg.cmd_factory.make_process_created_message()
|
||||
dbg.writer.add_command(cmd)
|
||||
|
||||
def _on_set_trace_for_new_thread(global_debugger):
|
||||
if global_debugger is not None:
|
||||
global_debugger.SetTrace(global_debugger.trace_dispatch)
|
||||
@@ -458,6 +463,10 @@ def create_fork(original_name):
|
||||
if not child_process:
|
||||
if is_new_python_process:
|
||||
_on_forked_process()
|
||||
else:
|
||||
if is_new_python_process:
|
||||
from _pydevd_bundle.pydevd_comm import get_global_debugger
|
||||
_notify_process_created(get_global_debugger())
|
||||
return child_process
|
||||
return new_fork
|
||||
|
||||
|
||||
@@ -143,6 +143,8 @@ CMD_SHOW_RETURN_VALUES = 146
|
||||
CMD_INPUT_REQUESTED = 147
|
||||
CMD_GET_DESCRIPTION = 148
|
||||
|
||||
CMD_PROCESS_CREATED = 149
|
||||
|
||||
CMD_VERSION = 501
|
||||
CMD_RETURN = 502
|
||||
CMD_ERROR = 901
|
||||
@@ -199,6 +201,8 @@ ID_TO_MEANING = {
|
||||
'147': 'CMD_INPUT_REQUESTED',
|
||||
'148': 'CMD_GET_DESCRIPTION',
|
||||
|
||||
'149': 'CMD_PROCESS_CREATED',
|
||||
|
||||
'501': 'CMD_VERSION',
|
||||
'502': 'CMD_RETURN',
|
||||
'901': 'CMD_ERROR',
|
||||
@@ -559,6 +563,9 @@ class NetCommandFactory:
|
||||
cmdText = "<xml>" + self._thread_to_xml(thread) + "</xml>"
|
||||
return NetCommand(CMD_THREAD_CREATE, 0, cmdText)
|
||||
|
||||
def make_process_created_message(self):
|
||||
cmdText = '<process/>'
|
||||
return NetCommand(CMD_PROCESS_CREATED, 0, cmdText)
|
||||
|
||||
def make_custom_frame_created_message(self, frameId, frameDescription):
|
||||
frameDescription = pydevd_xml.make_valid_xml_value(frameDescription)
|
||||
|
||||
@@ -54,6 +54,7 @@ public abstract class AbstractCommand<T> {
|
||||
public static final int SHOW_RETURN_VALUES = 146;
|
||||
public static final int INPUT_REQUESTED = 147;
|
||||
|
||||
public static final int PROCESS_CREATED = 149;
|
||||
|
||||
public static final int ERROR = 901;
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.jetbrains.python.debugger.pydev;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Alexander Koshevoy
|
||||
*/
|
||||
public class ProcessCreatedCommand extends AbstractCommand<ProcessCreatedCommand> {
|
||||
public ProcessCreatedCommand(@NotNull RemoteDebugger debugger, int commandCode) {
|
||||
super(debugger, commandCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildPayload(Payload payload) {
|
||||
}
|
||||
|
||||
public static boolean isProcessCreatedCommand(int command) {
|
||||
return command == AbstractCommand.PROCESS_CREATED;
|
||||
}
|
||||
}
|
||||
@@ -452,6 +452,9 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
else if (AbstractCommand.isInputRequested(frame.getCommand())) {
|
||||
myDebugProcess.consoleInputRequested(ProtocolParser.parseInputCommand(frame.getPayload()));
|
||||
}
|
||||
else if (ProcessCreatedCommand.isProcessCreatedCommand(frame.getCommand())) {
|
||||
onProcessCreatedEvent();
|
||||
}
|
||||
else {
|
||||
placeResponse(frame.getSequence(), frame);
|
||||
}
|
||||
@@ -636,6 +639,9 @@ public class RemoteDebugger implements ProcessDebugger {
|
||||
}
|
||||
}
|
||||
|
||||
protected void onProcessCreatedEvent() throws PyDebuggerException {
|
||||
}
|
||||
|
||||
protected void fireCloseEvent() {
|
||||
for (RemoteDebuggerCloseListener listener : myCloseListeners) {
|
||||
listener.closed();
|
||||
|
||||
Reference in New Issue
Block a user