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
64ccdc7e
Commit
64ccdc7e
authored
15 years ago
by
hjk
Browse files
Options
Downloads
Patches
Plain Diff
debugger: fix attaching to core file
parent
ec84f729
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/debugger/gdb/coregdbadapter.cpp
+62
-17
62 additions, 17 deletions
src/plugins/debugger/gdb/coregdbadapter.cpp
src/plugins/debugger/gdb/coregdbadapter.h
+3
-1
3 additions, 1 deletion
src/plugins/debugger/gdb/coregdbadapter.h
with
65 additions
and
18 deletions
src/plugins/debugger/gdb/coregdbadapter.cpp
+
62
−
17
View file @
64ccdc7e
...
...
@@ -119,32 +119,59 @@ void CoreGdbAdapter::prepareInferior()
void
CoreGdbAdapter
::
startInferior
()
{
QTC_ASSERT
(
state
()
==
InferiorStarting
,
qDebug
()
<<
state
());
QFileInfo
fi2
(
startParameters
().
coreFile
);
// quoting core name below fails in gdb 6.8-debian
m_executable
.
clear
();
QString
coreName
=
fi2
.
absoluteFilePath
();
m_engine
->
postCommand
(
_
(
"target core "
)
+
coreName
,
CB
(
handleTargetCore
));
QFileInfo
fi
(
startParameters
().
coreFile
);
m_executable
=
startParameters
().
executable
;
if
(
m_executable
.
isEmpty
())
{
// Extra round trip to get executable name from core file.
// This is sometimes not the full name, so it can't be used
// as the generic solution.
// Quoting core name below fails in gdb 6.8-debian.
QString
coreName
=
fi
.
absoluteFilePath
();
m_engine
->
postCommand
(
_
(
"target core "
)
+
coreName
,
CB
(
handleTargetCore1
));
}
else
{
// Directly load symbols.
QFileInfo
fi
(
m_executable
);
m_engine
->
postCommand
(
_
(
"-file-exec-and-symbols
\"
%1
\"
"
)
.
arg
(
fi
.
absoluteFilePath
()),
CB
(
handleFileExecAndSymbols
));
}
}
void
CoreGdbAdapter
::
handleTargetCore
(
const
GdbResponse
&
response
)
void
CoreGdbAdapter
::
handleTargetCore
1
(
const
GdbResponse
&
response
)
{
QTC_ASSERT
(
state
()
==
InferiorStarting
,
qDebug
()
<<
state
());
if
(
response
.
resultClass
==
GdbResultDone
)
{
showStatusMessage
(
tr
(
"Attached to core."
));
m_executable
=
startParameters
().
executable
;
if
(
m_executable
.
isEmpty
())
{
GdbMi
console
=
response
.
data
.
findChild
(
"consolestreamoutput"
);
int
pos1
=
console
.
data
().
indexOf
(
'`'
);
int
pos2
=
console
.
data
().
indexOf
(
'\''
);
if
(
pos1
!=
-
1
&&
pos2
!=
-
1
)
m_executable
=
console
.
data
().
mid
(
pos1
+
1
,
pos2
-
pos1
-
1
);
showStatusMessage
(
tr
(
"Attached to core temporarily."
));
GdbMi
console
=
response
.
data
.
findChild
(
"consolestreamoutput"
);
int
pos1
=
console
.
data
().
indexOf
(
'`'
);
int
pos2
=
console
.
data
().
indexOf
(
'\''
);
if
(
pos1
==
-
1
||
pos2
==
-
1
)
{
setState
(
InferiorStartFailed
);
emit
inferiorStartFailed
(
tr
(
"No binary found."
));
}
else
{
m_executable
=
console
.
data
().
mid
(
pos1
+
1
,
pos2
-
pos1
-
1
);
QTC_ASSERT
(
!
m_executable
.
isEmpty
(),
/**/
);
// Finish extra round.
m_engine
->
postCommand
(
_
(
"detach"
),
CB
(
handleDetach1
));
}
}
else
{
QTC_ASSERT
(
response
.
resultClass
==
GdbResultError
,
/**/
);
const
QByteArray
msg
=
response
.
data
.
findChild
(
"msg"
).
data
();
setState
(
InferiorStartFailed
);
emit
inferiorStartFailed
(
msg
);
}
}
void
CoreGdbAdapter
::
handleDetach1
(
const
GdbResponse
&
response
)
{
QTC_ASSERT
(
state
()
==
InferiorStarting
,
qDebug
()
<<
state
());
if
(
response
.
resultClass
==
GdbResultDone
)
{
// Load symbols.
QFileInfo
fi
(
m_executable
);
m_engine
->
postCommand
(
_
(
"-file-exec-and-symbols
\"
%1
\"
"
)
.
arg
(
fi
.
absoluteFilePath
()),
CB
(
handleFileExecAndSymbols
));
}
else
{
QTC_ASSERT
(
response
.
resultClass
==
GdbResultError
,
/**/
);
const
QByteArray
&
msg
=
response
.
data
.
findChild
(
"msg"
).
data
();
const
QByteArray
msg
=
response
.
data
.
findChild
(
"msg"
).
data
();
setState
(
InferiorStartFailed
);
emit
inferiorStartFailed
(
msg
);
}
...
...
@@ -155,8 +182,10 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
QTC_ASSERT
(
state
()
==
InferiorStarting
,
qDebug
()
<<
state
());
if
(
response
.
resultClass
==
GdbResultDone
)
{
showStatusMessage
(
tr
(
"Symbols found."
));
setState
(
InferiorUnrunnable
);
m_engine
->
updateAll
();
// Quoting core name below fails in gdb 6.8-debian.
QFileInfo
fi
(
startParameters
().
coreFile
);
QString
coreName
=
fi
.
absoluteFilePath
();
m_engine
->
postCommand
(
_
(
"target core "
)
+
coreName
,
CB
(
handleTargetCore2
));
}
else
if
(
response
.
resultClass
==
GdbResultError
)
{
QString
msg
=
tr
(
"Symbols not found in
\"
%1
\"
failed:
\n
%2"
)
.
arg
(
__
(
response
.
data
.
findChild
(
"msg"
).
data
()));
...
...
@@ -167,6 +196,22 @@ void CoreGdbAdapter::handleFileExecAndSymbols(const GdbResponse &response)
}
}
void
CoreGdbAdapter
::
handleTargetCore2
(
const
GdbResponse
&
response
)
{
QTC_ASSERT
(
state
()
==
InferiorStarting
,
qDebug
()
<<
state
());
if
(
response
.
resultClass
==
GdbResultDone
)
{
showStatusMessage
(
tr
(
"Attached to core."
));
setState
(
InferiorUnrunnable
);
m_engine
->
updateAll
();
}
else
if
(
response
.
resultClass
==
GdbResultError
)
{
QString
msg
=
tr
(
"Attach to core
\"
%1
\"
failed:
\n
%2"
)
.
arg
(
__
(
response
.
data
.
findChild
(
"msg"
).
data
()));
setState
(
InferiorUnrunnable
);
m_engine
->
updateAll
();
//setState(InferiorStartFailed);
// emit inferiorStartFailed(msg);
}
}
void
CoreGdbAdapter
::
interruptInferior
()
{
// A core should never 'run'
...
...
This diff is collapsed.
Click to expand it.
src/plugins/debugger/gdb/coregdbadapter.h
+
3
−
1
View file @
64ccdc7e
...
...
@@ -67,8 +67,10 @@ private:
void
interruptInferior
();
void
shutdown
();
void
handleTargetCore1
(
const
GdbResponse
&
response
);
void
handleDetach1
(
const
GdbResponse
&
response
);
void
handleFileExecAndSymbols
(
const
GdbResponse
&
response
);
void
handleTargetCore
(
const
GdbResponse
&
response
);
void
handleTargetCore
2
(
const
GdbResponse
&
response
);
void
handleExit
(
const
GdbResponse
&
response
);
Q_SLOT
void
handleGdbStarted
();
...
...
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