Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
00a9c053
Commit
00a9c053
authored
16 years ago
by
hjk
Browse files
Options
Downloads
Patches
Plain Diff
Fixes: debugger: forgot to add these
parent
f0a986f2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/debugger/debuggerdialogs.cpp
+323
-0
323 additions, 0 deletions
src/plugins/debugger/debuggerdialogs.cpp
src/plugins/debugger/debuggerdialogs.h
+112
-0
112 additions, 0 deletions
src/plugins/debugger/debuggerdialogs.h
with
435 additions
and
0 deletions
src/plugins/debugger/debuggerdialogs.cpp
0 → 100644
+
323
−
0
View file @
00a9c053
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include
"debuggerdialogs.h"
#include
<QtCore/QDebug>
#include
<QtCore/QDir>
#include
<QtCore/QFile>
#include
<QtGui/QStandardItemModel>
#include
<QtGui/QHeaderView>
#include
<QtGui/QFileDialog>
#include
<QtGui/QPushButton>
#ifdef Q_OS_WINDOWS
#include
<windows.h>
#include
<tlhelp32.h>
#include
<tchar.h>
#include
<stdio.h>
#endif
using
namespace
Debugger
::
Internal
;
///////////////////////////////////////////////////////////////////////
//
// AttachCoreDialog
//
///////////////////////////////////////////////////////////////////////
AttachCoreDialog
::
AttachCoreDialog
(
QWidget
*
parent
)
:
QDialog
(
parent
)
{
setupUi
(
this
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
//connect(procView, SIGNAL(activated(const QModelIndex &)),
// this, SLOT(procSelected(const QModelIndex &)));
}
///////////////////////////////////////////////////////////////////////
//
// AttachExternalDialog
//
///////////////////////////////////////////////////////////////////////
AttachExternalDialog
::
AttachExternalDialog
(
QWidget
*
parent
)
:
QDialog
(
parent
)
{
setupUi
(
this
);
buttonBox
->
button
(
QDialogButtonBox
::
Ok
)
->
setDefault
(
true
);
m_model
=
new
QStandardItemModel
(
this
);
procView
->
setSortingEnabled
(
true
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
connect
(
procView
,
SIGNAL
(
activated
(
const
QModelIndex
&
)),
this
,
SLOT
(
procSelected
(
const
QModelIndex
&
)));
rebuildProcessList
();
}
static
bool
isProcessName
(
const
QString
&
procname
)
{
for
(
int
i
=
0
;
i
!=
procname
.
size
();
++
i
)
if
(
!
procname
.
at
(
i
).
isDigit
())
return
false
;
return
true
;
}
struct
ProcData
{
QString
ppid
;
QString
name
;
QString
state
;
};
static
void
insertItem
(
QStandardItem
*
root
,
const
QString
&
pid
,
const
QMap
<
QString
,
ProcData
>
&
procs
,
QMap
<
QString
,
QStandardItem
*>
&
known
)
{
//qDebug() << "HANDLING " << pid;
QStandardItem
*
parent
=
0
;
const
ProcData
&
proc
=
procs
[
pid
];
if
(
1
||
pid
==
"0"
)
{
// FIXME: a real tree is not-so-nice to search
parent
=
root
;
}
else
{
if
(
!
known
.
contains
(
proc
.
ppid
))
insertItem
(
root
,
proc
.
ppid
,
procs
,
known
);
parent
=
known
[
proc
.
ppid
];
}
QList
<
QStandardItem
*>
row
;
row
.
append
(
new
QStandardItem
(
pid
));
row
.
append
(
new
QStandardItem
(
proc
.
name
));
//row.append(new QStandardItem(proc.ppid));
row
.
append
(
new
QStandardItem
(
proc
.
state
));
parent
->
appendRow
(
row
);
known
[
pid
]
=
row
[
0
];
}
void
AttachExternalDialog
::
rebuildProcessList
()
{
QStringList
procnames
=
QDir
(
"/proc/"
).
entryList
();
if
(
procnames
.
isEmpty
())
{
procView
->
hide
();
return
;
}
typedef
QMap
<
QString
,
ProcData
>
Procs
;
Procs
procs
;
foreach
(
const
QString
&
procname
,
procnames
)
{
if
(
!
isProcessName
(
procname
))
continue
;
QString
filename
=
"/proc/"
+
procname
+
"/stat"
;
QFile
file
(
filename
);
file
.
open
(
QIODevice
::
ReadOnly
);
QStringList
data
=
QString
::
fromLocal8Bit
(
file
.
readAll
()).
split
(
' '
);
//qDebug() << filename << data;
ProcData
proc
;
proc
.
name
=
data
.
at
(
1
);
if
(
proc
.
name
.
startsWith
(
'('
)
&&
proc
.
name
.
endsWith
(
')'
))
proc
.
name
=
proc
.
name
.
mid
(
1
,
proc
.
name
.
size
()
-
2
);
proc
.
state
=
data
.
at
(
2
);
proc
.
ppid
=
data
.
at
(
3
);
procs
[
procname
]
=
proc
;
}
m_model
->
clear
();
QMap
<
QString
,
QStandardItem
*>
known
;
for
(
Procs
::
const_iterator
it
=
procs
.
begin
();
it
!=
procs
.
end
();
++
it
)
insertItem
(
m_model
->
invisibleRootItem
(),
it
.
key
(),
procs
,
known
);
m_model
->
setHeaderData
(
0
,
Qt
::
Horizontal
,
"Process ID"
,
Qt
::
DisplayRole
);
m_model
->
setHeaderData
(
1
,
Qt
::
Horizontal
,
"Name"
,
Qt
::
DisplayRole
);
//model->setHeaderData(2, Qt::Horizontal, "Parent", Qt::DisplayRole);
m_model
->
setHeaderData
(
2
,
Qt
::
Horizontal
,
"State"
,
Qt
::
DisplayRole
);
procView
->
setModel
(
m_model
);
procView
->
expandAll
();
procView
->
resizeColumnToContents
(
0
);
procView
->
resizeColumnToContents
(
1
);
procView
->
sortByColumn
(
1
,
Qt
::
AscendingOrder
);
}
void
AttachExternalDialog
::
procSelected
(
const
QModelIndex
&
index0
)
{
QModelIndex
index
=
index0
.
sibling
(
index0
.
row
(),
0
);
QStandardItem
*
item
=
m_model
->
itemFromIndex
(
index
);
if
(
!
item
)
return
;
pidLineEdit
->
setText
(
item
->
text
());
accept
();
}
int
AttachExternalDialog
::
attachPID
()
const
{
return
pidLineEdit
->
text
().
toInt
();
}
///////////////////////////////////////////////////////////////////////
//
// AttachRemoteDialog
//
///////////////////////////////////////////////////////////////////////
AttachRemoteDialog
::
AttachRemoteDialog
(
QWidget
*
parent
,
const
QString
&
pid
)
:
QDialog
(
parent
)
{
setupUi
(
this
);
buttonBox
->
button
(
QDialogButtonBox
::
Ok
)
->
setDefault
(
true
);
m_defaultPID
=
pid
;
m_model
=
new
QStandardItemModel
(
this
);
procView
->
setSortingEnabled
(
true
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
connect
(
procView
,
SIGNAL
(
activated
(
const
QModelIndex
&
)),
this
,
SLOT
(
procSelected
(
const
QModelIndex
&
)));
pidLineEdit
->
setText
(
m_defaultPID
);
rebuildProcessList
();
}
void
AttachRemoteDialog
::
rebuildProcessList
()
{
QStringList
procnames
=
QDir
(
"/proc/"
).
entryList
();
if
(
procnames
.
isEmpty
())
{
procView
->
hide
();
return
;
}
typedef
QMap
<
QString
,
ProcData
>
Procs
;
Procs
procs
;
foreach
(
const
QString
&
procname
,
procnames
)
{
if
(
!
isProcessName
(
procname
))
continue
;
QString
filename
=
"/proc/"
+
procname
+
"/stat"
;
QFile
file
(
filename
);
file
.
open
(
QIODevice
::
ReadOnly
);
QStringList
data
=
QString
::
fromLocal8Bit
(
file
.
readAll
()).
split
(
' '
);
//qDebug() << filename << data;
ProcData
proc
;
proc
.
name
=
data
.
at
(
1
);
if
(
proc
.
name
.
startsWith
(
'('
)
&&
proc
.
name
.
endsWith
(
')'
))
proc
.
name
=
proc
.
name
.
mid
(
1
,
proc
.
name
.
size
()
-
2
);
proc
.
state
=
data
.
at
(
2
);
proc
.
ppid
=
data
.
at
(
3
);
procs
[
procname
]
=
proc
;
}
m_model
->
clear
();
QMap
<
QString
,
QStandardItem
*>
known
;
for
(
Procs
::
const_iterator
it
=
procs
.
begin
();
it
!=
procs
.
end
();
++
it
)
insertItem
(
m_model
->
invisibleRootItem
(),
it
.
key
(),
procs
,
known
);
m_model
->
setHeaderData
(
0
,
Qt
::
Horizontal
,
"Process ID"
,
Qt
::
DisplayRole
);
m_model
->
setHeaderData
(
1
,
Qt
::
Horizontal
,
"Name"
,
Qt
::
DisplayRole
);
//model->setHeaderData(2, Qt::Horizontal, "Parent", Qt::DisplayRole);
m_model
->
setHeaderData
(
2
,
Qt
::
Horizontal
,
"State"
,
Qt
::
DisplayRole
);
procView
->
setModel
(
m_model
);
procView
->
expandAll
();
procView
->
resizeColumnToContents
(
0
);
procView
->
resizeColumnToContents
(
1
);
}
void
AttachRemoteDialog
::
procSelected
(
const
QModelIndex
&
index0
)
{
QModelIndex
index
=
index0
.
sibling
(
index0
.
row
(),
0
);
QStandardItem
*
item
=
m_model
->
itemFromIndex
(
index
);
if
(
!
item
)
return
;
pidLineEdit
->
setText
(
item
->
text
());
accept
();
}
int
AttachRemoteDialog
::
attachPID
()
const
{
return
pidLineEdit
->
text
().
toInt
();
}
///////////////////////////////////////////////////////////////////////
//
// StartExternalDialog
//
///////////////////////////////////////////////////////////////////////
StartExternalDialog
::
StartExternalDialog
(
QWidget
*
parent
)
:
QDialog
(
parent
)
{
setupUi
(
this
);
execFile
->
setExpectedKind
(
Core
::
Utils
::
PathChooser
::
File
);
execFile
->
setPromptDialogTitle
(
tr
(
"Select Executable"
));
buttonBox
->
button
(
QDialogButtonBox
::
Ok
)
->
setDefault
(
true
);
//execLabel->setHidden(false);
//execEdit->setHidden(false);
//browseButton->setHidden(false);
execLabel
->
setText
(
tr
(
"Executable:"
));
argLabel
->
setText
(
tr
(
"Arguments:"
));
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
}
void
StartExternalDialog
::
setExecutableFile
(
const
QString
&
str
)
{
execFile
->
setPath
(
str
);
}
void
StartExternalDialog
::
setExecutableArguments
(
const
QString
&
str
)
{
argsEdit
->
setText
(
str
);
}
QString
StartExternalDialog
::
executableFile
()
const
{
return
execFile
->
path
();
}
QString
StartExternalDialog
::
executableArguments
()
const
{
return
argsEdit
->
text
();
}
This diff is collapsed.
Click to expand it.
src/plugins/debugger/debuggerdialogs.h
0 → 100644
+
112
−
0
View file @
00a9c053
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef DEBUGGER_DIALOGS_H
#define DEBUGGER_DIALOGS_H
#include
"ui_attachcoredialog.h"
#include
"ui_attachexternaldialog.h"
#include
"ui_attachremotedialog.h"
#include
"ui_startexternaldialog.h"
QT_BEGIN_NAMESPACE
class
QStandardItemModel
;
QT_END_NAMESPACE
namespace
Debugger
{
namespace
Internal
{
class
AttachCoreDialog
:
public
QDialog
,
Ui
::
AttachCoreDialog
{
Q_OBJECT
public:
explicit
AttachCoreDialog
(
QWidget
*
parent
);
void
setExecutableFile
(
const
QString
&
executable
);
void
setCoreFile
(
const
QString
&
core
);
QString
executableFile
()
const
;
QString
coreFile
()
const
;
};
class
AttachExternalDialog
:
public
QDialog
,
Ui
::
AttachExternalDialog
{
Q_OBJECT
public:
explicit
AttachExternalDialog
(
QWidget
*
parent
);
int
attachPID
()
const
;
private
slots
:
void
rebuildProcessList
();
void
procSelected
(
const
QModelIndex
&
);
private:
QStandardItemModel
*
m_model
;
};
class
AttachRemoteDialog
:
public
QDialog
,
Ui
::
AttachRemoteDialog
{
Q_OBJECT
public:
explicit
AttachRemoteDialog
(
QWidget
*
parent
,
const
QString
&
pid
);
int
attachPID
()
const
;
private
slots
:
void
rebuildProcessList
();
void
procSelected
(
const
QModelIndex
&
);
private:
QString
m_defaultPID
;
QStandardItemModel
*
m_model
;
};
class
StartExternalDialog
:
public
QDialog
,
Ui
::
StartExternalDialog
{
Q_OBJECT
public:
explicit
StartExternalDialog
(
QWidget
*
parent
);
void
setExecutableFile
(
const
QString
&
executable
);
void
setExecutableArguments
(
const
QString
&
args
);
QString
executableFile
()
const
;
QString
executableArguments
()
const
;
};
}
// namespace Debugger
}
// namespace Internal
#endif // DEBUGGER_DIALOGS_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment