mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-17 06:06:00 -06:00
Ide/Debuggers : fixed a crash on Gdb_MI2 frontend
git-svn-id: svn://ultimatepp.org/upp/trunk@4509 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a5f4cebeae
commit
1987b514bb
4 changed files with 50 additions and 19 deletions
|
|
@ -550,9 +550,19 @@ void Gdb_MI2::SyncDisas(MIValue &fInfo, bool fr)
|
|||
adr_t adr = stou(~fInfo["addr"].Get().Mid(2), NULL, 16);
|
||||
if(!disas.InRange(adr))
|
||||
{
|
||||
String file = fInfo["file"];
|
||||
String line = fInfo["line"];
|
||||
MIValue code = MICmd(Format("data-disassemble -f %s -l %s -n -1 -- 0", file, line))["asm_insns"];
|
||||
MIValue code;
|
||||
|
||||
// if frame is inside a source file, disassemble current function
|
||||
if(fInfo.Find("file") >= 0 && fInfo.Find("line") >= 0)
|
||||
{
|
||||
String file = fInfo["file"];
|
||||
String line = fInfo["line"];
|
||||
code = MICmd(Format("data-disassemble -f %s -l %s -n -1 -- 0", file, line))["asm_insns"];
|
||||
}
|
||||
else
|
||||
// otherwise disassemble some -100 ... +100 bytes around address
|
||||
code = MICmd(Format("data-disassemble -s %x -e %x -- 0", (void *)(adr - 100), (void *)(adr + 100)))["asm_insns"];
|
||||
|
||||
disas.Clear();
|
||||
for(int iLine = 0; iLine < code.GetCount(); iLine++)
|
||||
{
|
||||
|
|
@ -606,6 +616,17 @@ void Gdb_MI2::SyncIde(bool fr)
|
|||
SyncDisas(fInfo, fr);
|
||||
}
|
||||
|
||||
// logs frame data on console
|
||||
void Gdb_MI2::LogFrame(String const &msg, MIValue &frame)
|
||||
{
|
||||
String file = frame("file", "<unknown>");
|
||||
String line = frame("line", "<unknown>");
|
||||
String function = frame("function", "<unknown>");
|
||||
String addr = frame("addr", "<unknown>");
|
||||
|
||||
PutConsole(Format(msg + " at %s, function '%s', file '%s', line %s", addr, function, file, line));
|
||||
}
|
||||
|
||||
// check for stop reason
|
||||
void Gdb_MI2::CheckStopReason(void)
|
||||
{
|
||||
|
|
@ -623,22 +644,12 @@ void Gdb_MI2::CheckStopReason(void)
|
|||
}
|
||||
else if(reason == "breakpoint-hit")
|
||||
{
|
||||
MIValue &v = stopReason["frame"];
|
||||
String file = v["file"];
|
||||
String line = v["line"];
|
||||
String function = v["func"];
|
||||
String addr = v["addr"];
|
||||
PutConsole(Format("Hit breakpoint at %s, function '%s', file '%s', line %s", addr, function, file, line));
|
||||
LogFrame("Hit breakpoint", stopReason["frame"]);
|
||||
SyncIde();
|
||||
}
|
||||
else
|
||||
{
|
||||
MIValue &v = stopReason["frame"];
|
||||
String file = v["file"];
|
||||
String line = v["line"];
|
||||
String function = v["func"];
|
||||
String addr = v["addr"];
|
||||
PutConsole(Format("Stopped at %s, function '%s', file '%s', line %s, reason '%s'", addr, function, file, line, stopReason["reason"].Get()));
|
||||
LogFrame(Format("Stopped, reason '%s'", reason), stopReason["frame"]);
|
||||
SyncIde();
|
||||
}
|
||||
}
|
||||
|
|
@ -707,9 +718,9 @@ void Gdb_MI2::DisasFocus()
|
|||
String Gdb_MI2::FormatFrame(MIValue &fInfo, MIValue &fArgs)
|
||||
{
|
||||
int idx = atoi(fInfo["level"].Get());
|
||||
String func = fInfo["func"];
|
||||
String file = fInfo["file"];
|
||||
String line = fInfo["line"];
|
||||
String func = fInfo("func", "<unknown>");
|
||||
String file = fInfo("file", "<unknown>");
|
||||
String line = fInfo("line", "<unknown>");
|
||||
int nArgs = fArgs.GetCount();
|
||||
String argLine;
|
||||
for(int iArg = 0; iArg < nArgs; iArg++)
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ class Gdb_MI2 : public Debugger, public ParentCtrl
|
|||
// update local variables on demand
|
||||
void UpdateLocalVars(void);
|
||||
|
||||
// logs frame data on console
|
||||
void LogFrame(String const &msg, MIValue &frame);
|
||||
|
||||
// check for stop reason
|
||||
void CheckStopReason(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -261,6 +261,20 @@ String const &MIValue::Get(void) const
|
|||
return string;
|
||||
}
|
||||
|
||||
// tuple string member accessor with default value if not found
|
||||
String MIValue::Get(const char *key, const char *def) const
|
||||
{
|
||||
ASSERT(type == MITuple);
|
||||
int i = tuple.Find(key);
|
||||
if(i >= 0)
|
||||
{
|
||||
ASSERT(tuple[i].type == MIString);
|
||||
return tuple[i];
|
||||
}
|
||||
else
|
||||
return def;
|
||||
}
|
||||
|
||||
// data dump
|
||||
String MIValue::Dump(int level)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ class MIValue : public Moveable<MIValue>
|
|||
operator const String &() const { return Get(); }
|
||||
String &ToString(void) { return Get(); }
|
||||
String const &ToString(void) const { return Get(); }
|
||||
// operator const char *() { return Get(); }
|
||||
|
||||
// tuple string member accessor with default value if not found
|
||||
String Get(const char *key, const char *def) const;
|
||||
String operator()(const char *key, const char *def) const { return Get(key, def); }
|
||||
|
||||
// some type checking
|
||||
bool IsArray(void) { return type == MIArray; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue