Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
f2e9ed46
Commit
f2e9ed46
authored
7 years ago
by
Viuginov Nickolay
Browse files
Options
Download
Email Patches
Plain Diff
wip
parent
51e1f703
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
platform/platform-impl/src/com/intellij/execution/process/impl/ProcessListUtil.java
+1
-6
.../com/intellij/execution/process/impl/ProcessListUtil.java
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/EnvironmentAwareHost.java
+25
-15
...c/com/intellij/xdebugger/attach/EnvironmentAwareHost.java
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/LocalAttachHost.java
+7
-7
...pl/src/com/intellij/xdebugger/attach/LocalAttachHost.java
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/XAttachHost.java
+0
-5
...r-impl/src/com/intellij/xdebugger/attach/XAttachHost.java
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/XAttachHostProvider.java
+3
-1
...rc/com/intellij/xdebugger/attach/XAttachHostProvider.java
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/XAttachPresentationGroup.java
+18
-2
...m/intellij/xdebugger/attach/XAttachPresentationGroup.java
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/fs/LazyAttachVirtualFS.java
+1
-1
...com/intellij/xdebugger/attach/fs/LazyAttachVirtualFS.java
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AttachToProcessAction.java
+1
-1
...ntellij/xdebugger/impl/actions/AttachToProcessAction.java
with
56 additions
and
38 deletions
+56
-38
platform/platform-impl/src/com/intellij/execution/process/impl/ProcessListUtil.java
+
1
-
6
View file @
f2e9ed46
...
...
@@ -174,12 +174,7 @@ public class ProcessListUtil {
}
@Nullable
public
static
List
<
ProcessInfo
>
parseProcessInfos
(
@NotNull
String
commandOnly
,
@NotNull
String
full
)
{
return
parseMacOutput
(
commandOnly
,
full
);
}
@Nullable
static
List
<
ProcessInfo
>
parseMacOutput
(
@NotNull
String
commandOnly
,
@NotNull
String
full
)
{
public
static
List
<
ProcessInfo
>
parseMacOutput
(
@NotNull
String
commandOnly
,
@NotNull
String
full
)
{
List
<
MacProcessInfo
>
commands
=
doParseMacOutput
(
commandOnly
);
List
<
MacProcessInfo
>
fulls
=
doParseMacOutput
(
full
);
if
(
commands
==
null
||
fulls
==
null
)
return
null
;
...
...
This diff is collapsed.
Click to expand it.
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/EnvironmentAwareHost.java
+
25
-
15
View file @
f2e9ed46
...
...
@@ -3,6 +3,8 @@ package com.intellij.xdebugger.attach;
import
com.intellij.execution.ExecutionException
;
import
com.intellij.execution.configurations.GeneralCommandLine
;
import
com.intellij.execution.process.BaseProcessHandler
;
import
com.intellij.execution.process.CapturingProcessRunner
;
import
com.intellij.execution.process.ProcessInfo
;
import
com.intellij.execution.process.ProcessOutput
;
import
com.intellij.openapi.project.Project
;
...
...
@@ -14,28 +16,40 @@ import org.jetbrains.annotations.Nullable;
import
java.io.InputStream
;
import
java.util.Arrays
;
/**
* This abstract class represent {@link XAttachHost} with extended functional, such as executing {@link GeneralCommandLine},
* downloading remote files and getting OS of a remote host
*/
@ApiStatus
.
Experimental
public
abstract
class
EnvironmentAwareHost
implements
XAttachHost
{
private
OSType
myOSType
;
/**
* @param command commandLine to execute on this host
* @param command
Line
commandLine to execute on this host
* @return output of the corresponding process
*/
@NotNull
public
abstract
Process
Output
execAndGetOutput
(
@Nullable
Project
project
,
@NotNull
GeneralCommandLine
command
)
throws
ExecutionException
;
public
abstract
Base
Process
Handler
getProcessHandler
(
@Nullable
Project
project
,
@NotNull
GeneralCommandLine
command
Line
)
throws
ExecutionException
;
@NotNull
public
ProcessOutput
getProcessOutput
(
@Nullable
Project
project
,
@NotNull
GeneralCommandLine
commandLine
)
throws
ExecutionException
{
BaseProcessHandler
handler
=
getProcessHandler
(
project
,
commandLine
);
CapturingProcessRunner
runner
=
new
CapturingProcessRunner
(
handler
);
return
runner
.
runProcess
();
}
/**
* Retrieves remote file contents stream. May be used to sync parts of the debugged project.
* @param remotePath host-dependent path
*
* @param filePath host-dependent path
* @return stream with file contents or <code>null</code> if the specified file does not exist
* @throws ExecutionException on stream retrieval error
*/
@Nullable
public
abstract
InputStream
get
Remote
File
(
@NotNull
String
remot
ePath
)
throws
ExecutionException
;
public
abstract
InputStream
getFile
(
@NotNull
String
fil
ePath
)
throws
ExecutionException
;
/**
* @return uid of user or -1 if error occurred
...
...
@@ -56,31 +70,28 @@ public abstract class EnvironmentAwareHost implements XAttachHost {
}
}
private
int
getUidUnix
(
Project
project
)
throws
ExecutionException
{
private
int
getUidUnix
(
@Nullable
Project
project
)
throws
ExecutionException
{
GeneralCommandLine
commandLine
=
new
GeneralCommandLine
(
Arrays
.
asList
(
"id"
,
"-u"
));
ProcessOutput
uidOutput
=
execAndGetOutput
(
project
,
commandLine
);
String
uid
=
uidOutput
.
getStdout
().
trim
();
String
uid
=
getProcessOutput
(
project
,
commandLine
).
getStdout
();
try
{
return
Integer
.
valueOf
(
uid
);
}
catch
(
NumberFormatException
e
)
{
throw
new
ExecutionException
(
"Error while parsing uid
"
);
throw
new
ExecutionException
(
"Error while parsing uid
from "
+
uid
+
"\n"
+
e
);
}
}
public
OSType
getOsType
(
Project
project
)
throws
ExecutionException
{
@NotNull
public
OSType
getOsType
(
@Nullable
Project
project
)
throws
ExecutionException
{
if
(
myOSType
!=
null
)
{
return
myOSType
;
}
try
{
GeneralCommandLine
getOsCommandLine
=
new
GeneralCommandLine
(
"uname"
,
"-s"
);
ProcessOutput
getOsOutput
=
execAndGetOutput
(
project
,
getOsCommandLine
);
String
osString
=
getOsOutput
.
getStdout
().
trim
();
final
String
osString
=
getProcessOutput
(
project
,
getOsCommandLine
).
getStdout
().
trim
();
OSType
osType
;
...
...
@@ -98,7 +109,6 @@ public abstract class EnvironmentAwareHost implements XAttachHost {
osType
=
OSType
.
UNKNOWN
;
break
;
}
return
myOSType
=
osType
;
}
catch
(
ExecutionException
ex
)
{
...
...
This diff is collapsed.
Click to expand it.
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/LocalAttachHost.java
+
7
-
7
View file @
f2e9ed46
...
...
@@ -3,9 +3,10 @@ package com.intellij.xdebugger.attach;
import
com.intellij.execution.ExecutionException
;
import
com.intellij.execution.configurations.GeneralCommandLine
;
import
com.intellij.execution.process.BaseProcessHandler
;
import
com.intellij.execution.process.CapturingProcessHandler
;
import
com.intellij.execution.process.OSProcessUtil
;
import
com.intellij.execution.process.ProcessInfo
;
import
com.intellij.execution.process.ProcessOutput
;
import
com.intellij.execution.util.ExecUtil
;
import
com.intellij.openapi.diagnostic.Logger
;
import
com.intellij.openapi.project.Project
;
...
...
@@ -55,15 +56,14 @@ public class LocalAttachHost extends EnvironmentAwareHost {
@NotNull
@Override
public
ProcessOutput
execAndGetOutput
(
@Nullable
Project
project
,
@NotNull
GeneralCommandLine
command
)
throws
ExecutionException
{
return
ExecUtil
.
execAndGetOutput
(
command
);
public
BaseProcessHandler
getProcessHandler
(
@Nullable
Project
project
,
@NotNull
GeneralCommandLine
commandLine
)
throws
ExecutionException
{
return
new
CapturingProcessHandler
(
commandLine
);
}
@Nullable
@Override
public
InputStream
get
Remote
File
(
@NotNull
String
remot
ePath
)
throws
ExecutionException
{
VirtualFile
file
=
LocalFileSystem
.
getInstance
().
findFileByPath
(
remot
ePath
);
public
InputStream
getFile
(
@NotNull
String
fil
ePath
)
throws
ExecutionException
{
VirtualFile
file
=
LocalFileSystem
.
getInstance
().
findFileByPath
(
fil
ePath
);
if
(
file
==
null
)
{
return
null
;
}
...
...
@@ -98,7 +98,7 @@ public class LocalAttachHost extends EnvironmentAwareHost {
private
static
boolean
isSudoNeededUnix
(
int
pid
)
{
/* TODO actually, if security level is 1 then depending on CAP_SYS_PTRACE or some predefined relationship with
* the target process we might can attach to it without sudo. Thats why we might need pid.
* the target process we might can attach to it without sudo. That
'
s why we might need pid.
*/
return
(
getPtraceScope
()
>
0
||
!
isSameUser
(
pid
));
}
...
...
This diff is collapsed.
Click to expand it.
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/XAttachHost.java
+
0
-
5
View file @
f2e9ed46
...
...
@@ -15,16 +15,11 @@
*/
package
com.intellij.xdebugger.attach
;
import
com.intellij.execution.ExecutionException
;
import
com.intellij.execution.configurations.GeneralCommandLine
;
import
com.intellij.execution.process.ProcessInfo
;
import
com.intellij.execution.process.ProcessOutput
;
import
com.intellij.openapi.project.Project
;
import
org.jetbrains.annotations.ApiStatus
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
This diff is collapsed.
Click to expand it.
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/XAttachHostProvider.java
+
3
-
1
View file @
f2e9ed46
...
...
@@ -16,7 +16,9 @@
package
com.intellij.xdebugger.attach
;
import
com.intellij.openapi.extensions.ExtensionPointName
;
import
com.intellij.openapi.project.Project
;
import
org.jetbrains.annotations.ApiStatus
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.List
;
...
...
@@ -36,6 +38,6 @@ public interface XAttachHostProvider<T extends XAttachHost> {
/**
* @return a list of connections of this type
*/
List
<
T
>
getAvailableHosts
();
List
<
T
>
getAvailableHosts
(
@NotNull
Project
project
);
}
This diff is collapsed.
Click to expand it.
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/XAttachPresentationGroup.java
+
18
-
2
View file @
f2e9ed46
...
...
@@ -33,13 +33,27 @@ public interface XAttachPresentationGroup<T> {
@NotNull
String
getGroupName
();
/**
* @deprecated Use {@link #getIcon(Project, Object, UserDataHolder)}
*/
@NotNull
Icon
getProcessIcon
(
@NotNull
Project
project
,
@NotNull
T
info
,
@NotNull
UserDataHolder
dataHolder
);
/**
* @param dataHolder you may put your specific data into the holder at previous step in method @{@link XAttachDebuggerProvider#getAvailableDebuggers}
* and use it for presentation
* @return an icon to be shown in popup menu for your item
*/
@NotNull
Icon
getIcon
(
@NotNull
Project
project
,
@NotNull
T
info
,
@NotNull
UserDataHolder
dataHolder
);
default
Icon
getIcon
(
@NotNull
Project
project
,
@NotNull
T
info
,
@NotNull
UserDataHolder
dataHolder
)
{
return
getProcessIcon
(
project
,
info
,
dataHolder
);
}
/**
* @deprecated Use {@link #getItemDisplayText(Project, Object, UserDataHolder)}
*/
@NotNull
String
getProcessDisplayText
(
@NotNull
Project
project
,
@NotNull
T
info
,
@NotNull
UserDataHolder
dataHolder
);
/**
* @param dataHolder you may put your specific data into the holder at previous step in method @{@link XAttachDebuggerProvider#getAvailableDebuggers}
...
...
@@ -47,7 +61,9 @@ public interface XAttachPresentationGroup<T> {
* @return a text to be shown on your item
*/
@NotNull
String
getItemDisplayText
(
@NotNull
Project
project
,
@NotNull
T
info
,
@NotNull
UserDataHolder
dataHolder
);
default
String
getItemDisplayText
(
@NotNull
Project
project
,
@NotNull
T
info
,
@NotNull
UserDataHolder
dataHolder
)
{
return
getProcessDisplayText
(
project
,
info
,
dataHolder
);
}
/**
* @param dataHolder you may put your specific data into the holder at previous step in method @{@link XAttachDebuggerProvider#getAvailableDebuggers}
...
...
This diff is collapsed.
Click to expand it.
platform/xdebugger-impl/src/com/intellij/xdebugger/attach/fs/LazyAttachVirtualFS.java
+
1
-
1
View file @
f2e9ed46
...
...
@@ -120,7 +120,7 @@ public class LazyAttachVirtualFS extends VirtualFileSystem {
@Nullable
private
static
String
getFileContent
(
@NotNull
EnvironmentAwareHost
host
,
@NotNull
String
path
)
throws
ExecutionException
{
InputStream
stream
=
host
.
get
Remote
File
(
path
);
InputStream
stream
=
host
.
getFile
(
path
);
if
(
stream
==
null
)
{
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/AttachToProcessAction.java
+
1
-
1
View file @
f2e9ed46
...
...
@@ -147,7 +147,7 @@ public class AttachToProcessAction extends AnAction {
for
(
XAttachHostProvider
hostProvider
:
hostProviders
)
{
//noinspection unchecked
List
<
XAttachHost
>
settingsList
=
hostProvider
.
getAvailableHosts
();
List
<
XAttachHost
>
settingsList
=
hostProvider
.
getAvailableHosts
(
project
);
for
(
XAttachHost
eachSettings
:
settingsList
)
{
groupWithItems
.
putValue
(
hostProvider
.
getPresentationGroup
(),
Pair
.
create
(
eachSettings
,
hostProvider
));
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help