Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
f5c8389a
Commit
f5c8389a
authored
Mar 04, 2010
by
Friedemann Kleint
Browse files
Debugger/Attach to running: Default to ps if /proc does not exist.
Polish the process dialog. Task-number: QTCREATORBUG-800
parent
57d3aa88
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/debuggerdialogs.cpp
View file @
f5c8389a
...
...
@@ -40,8 +40,10 @@
#endif
#include
<coreplugin/icore.h>
#include
<utils/synchronousprocess.h>
#include
<QtCore/QDebug>
#include
<QtCore/QProcess>
#include
<QtCore/QDir>
#include
<QtCore/QFile>
#include
<QtCore/QCoreApplication>
...
...
@@ -183,14 +185,55 @@ static bool isUnixProcessId(const QString &procname)
return
true
;
}
// Determine UNIX processes by reading "/proc"
// Determine UNIX processes by running ps
static
QList
<
ProcData
>
unixProcessListPS
()
{
#ifdef Q_OS_MAC
static
const
char
formatC
[]
=
"pid state command"
;
#else
static
const
char
formatC
[]
=
"pid,state,cmd"
;
#endif
QList
<
ProcData
>
rc
;
QProcess
psProcess
;
QStringList
args
;
args
<<
QLatin1String
(
"-e"
)
<<
QLatin1String
(
"-o"
)
<<
QLatin1String
(
formatC
);
psProcess
.
start
(
QLatin1String
(
"ps"
),
args
);
if
(
!
psProcess
.
waitForStarted
())
return
rc
;
QByteArray
output
;
if
(
!
Utils
::
SynchronousProcess
::
readDataFromProcess
(
psProcess
,
30000
,
&
output
))
return
rc
;
// Split "457 S+ /Users/foo.app"
const
QStringList
lines
=
QString
::
fromLocal8Bit
(
output
).
split
(
QLatin1Char
(
'\n'
));
const
int
lineCount
=
lines
.
size
();
const
QChar
blank
=
QLatin1Char
(
' '
);
for
(
int
l
=
1
;
l
<
lineCount
;
l
++
)
{
// Skip header
const
QString
line
=
lines
.
at
(
l
).
simplified
();
const
int
pidSep
=
line
.
indexOf
(
blank
);
const
int
cmdSep
=
pidSep
!=
-
1
?
line
.
indexOf
(
blank
,
pidSep
+
1
)
:
-
1
;
if
(
cmdSep
>
0
)
{
ProcData
procData
;
procData
.
ppid
=
line
.
left
(
pidSep
);
procData
.
state
=
line
.
mid
(
pidSep
+
1
,
cmdSep
-
pidSep
-
1
);
procData
.
name
=
line
.
mid
(
cmdSep
+
1
);
rc
.
push_back
(
procData
);
}
}
return
rc
;
}
// Determine UNIX processes by reading "/proc". Default to ps if
// it does not exist
static
QList
<
ProcData
>
unixProcessList
()
{
const
QDir
procDir
(
QLatin1String
(
"/proc/"
));
if
(
!
procDir
.
exists
())
return
unixProcessListPS
();
QList
<
ProcData
>
rc
;
const
QStringList
procIds
=
QDir
(
QLatin1String
(
"/proc/"
))
.
entryList
();
const
QStringList
procIds
=
procDir
.
entryList
();
if
(
procIds
.
isEmpty
())
return
rc
;
foreach
(
const
QString
&
procId
,
procIds
)
{
if
(
!
isUnixProcessId
(
procId
))
continue
;
...
...
@@ -250,6 +293,10 @@ AttachExternalDialog::AttachExternalDialog(QWidget *parent)
m_ui
->
buttonBox
->
addButton
(
refreshButton
,
QDialogButtonBox
::
ActionRole
);
m_ui
->
filterWidget
->
setFocus
(
Qt
::
TabFocusReason
);
m_ui
->
procView
->
setAlternatingRowColors
(
true
);
m_ui
->
procView
->
setRootIsDecorated
(
false
);
m_ui
->
procView
->
setUniformRowHeights
(
true
);
// Do not use activated, will be single click in Oxygen
connect
(
m_ui
->
procView
,
SIGNAL
(
doubleClicked
(
QModelIndex
)),
this
,
SLOT
(
procSelected
(
QModelIndex
)));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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