User forums > Using Code::Blocks
Debugger plugin issue when I click the "Setp into instruction"
oBFusCATed:
What happens if you replace \n with the \r\n?
ollydbg:
--- Quote from: oBFusCATed on January 12, 2019, 07:34:20 pm ---What happens if you replace \n with the \r\n?
--- End quote ---
I have already tried this yesterday, but this does not solve the issue.
Now, I have tried another patch:
--- Code: --- src/plugins/debuggergdb/gdb_commands.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/plugins/debuggergdb/gdb_commands.h b/src/plugins/debuggergdb/gdb_commands.h
index 65bc040e..448ea977 100644
--- a/src/plugins/debuggergdb/gdb_commands.h
+++ b/src/plugins/debuggergdb/gdb_commands.h
@@ -1496,21 +1496,21 @@ class GdbCmd_DisassemblyInit : public DebuggerCmd
m_disassemblyFlavor(disassemblyFlavor),
m_hexAddrStr(hexAddrStr)
{
- m_Cmd << _T("if 1\n") ;
+ //m_Cmd << _T("if 1\r\n") ;
if(m_hexAddrStr.empty())
{
const Cursor &cursor = driver->GetCursor() ;
if(cursor.address.empty())
- m_Cmd << _T("disassemble $pc,$pc+50\n") ;
+ m_Cmd << _T("disassemble $pc,$pc+50\r\n") ;
else
{
- m_Cmd << _T("disassemble ") << cursor.address << _T("\n") ;
+ m_Cmd << _T("disassemble ") << cursor.address<< _T("\r\n") ;
}
}
else
- m_Cmd << _T("disassemble ") << m_hexAddrStr << _T("\n") ;
+ m_Cmd << _T("disassemble ") << m_hexAddrStr;// << _T("\r\n") ;
- m_Cmd << _T("info frame\n") << _T("end");
+ m_Cmd << _T("info frame\r\n");// << _T("end");
};
void ParseOutput(const wxString& p_output)
--- End code ---
Which I remove the "if 1" and "end" command.
It looks like this works:
--- Code: ---[debug]>>>>>>cb_gdb:
At D:\code\gdb-test\main.cpp:13
[debug]> bt 30
[debug]#0 main () at main.cpp:13
[debug]>>>>>>cb_gdb:
[debug]> disassemble 0x401658
info frame
[debug]Dump of assembler code for function main():
[debug] 0x00401600 <+0>: lea 0x4(%esp),%ecx
[debug] 0x00401604 <+4>: and $0xfffffff0,%esp
[debug] 0x00401607 <+7>: pushl -0x4(%ecx)
[debug] 0x0040160a <+10>: push %ebp
[debug] 0x0040160b <+11>: mov %esp,%ebp
[debug] 0x0040160d <+13>: push %ecx
[debug] 0x0040160e <+14>: sub $0x24,%esp
[debug] 0x00401611 <+17>: call 0x401870 <__main>
[debug] 0x00401616 <+22>: movl $0x404045,0x4(%esp)
[debug] 0x0040161e <+30>: movl $0x6ff05a00,(%esp)
[debug] 0x00401625 <+37>: call 0x4016d4 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)>
[debug] 0x0040162a <+42>: movl $0x4016dc,(%esp)
[debug] 0x00401631 <+49>: mov %eax,%ecx
[debug] 0x00401633 <+51>: call 0x4016f4 <std::ostream::operator<<(std::ostream& (*)(std::ostream&))>
[debug] 0x00401638 <+56>: sub $0x4,%esp
[debug] 0x0040163b <+59>: movl $0x0,-0xc(%ebp)
[debug] 0x00401642 <+66>: movl $0x3,-0xc(%ebp)
[debug] 0x00401649 <+73>: movl $0x0,-0x10(%ebp)
[debug] 0x00401650 <+80>: addl $0x1,-0xc(%ebp)
[debug] 0x00401654 <+84>: addl $0x6,-0xc(%ebp)
[debug]=> 0x00401658 <+88>: mov -0xc(%ebp),%eax
[debug] 0x0040165b <+91>: add $0x1,%eax
[debug] 0x0040165e <+94>: mov %eax,-0x10(%ebp)
[debug] 0x00401661 <+97>: addl $0x1,-0x10(%ebp)
[debug] 0x00401665 <+101>: addl $0x4,-0x10(%ebp)
[debug] 0x00401669 <+105>: mov $0x0,%eax
[debug] 0x0040166e <+110>: mov -0x4(%ebp),%ecx
[debug] 0x00401671 <+113>: leave
[debug] 0x00401672 <+114>: lea -0x4(%ecx),%esp
[debug] 0x00401675 <+117>: ret
[debug]End of assembler dump.
[debug]>>>>>>cb_gdb:Stack level 0, frame at 0x28fed0:
Failure finding "Stack level "
[debug] eip = 0x401658 in main (main.cpp:13); saved eip = 0x4013eb
[debug] source language c++.
[debug] Arglist at 0x28feb8, args:
[debug] Locals at 0x28feb8, Previous frame's sp is 0x28fed0
[debug] Saved registers:
[debug] ebp at 0x28feb8, eip at 0x28fecc
[debug]>>>>>>cb_gdb:Stack level 0, frame at 0x28fed0:
[debug] eip = 0x401658 in main (main.cpp:13); saved eip = 0x4013eb
[debug] source language c++.
[debug] Arglist at 0x28feb8, args:
[debug] Locals at 0x28feb8, Previous frame's sp is 0x28fed0
[debug] Saved registers:
[debug] ebp at 0x28feb8, eip at 0x28fecc
[debug]>>>>>>cb_gdb:
--- End code ---
The GDB prompt returned correctly, but you see the error message from C::B: Failure finding "Stack level ".
ollydbg:
The code snippet of the parsing GDB return string is:
--- Code: ---
static wxString buffer;
buffer << output << _T('\n');
m_pDBG->DebugLog(output);
int idx = buffer.First(GDB_PROMPT);
const bool foundPrompt = (idx != wxNOT_FOUND);
if (!foundPrompt)
{
// don't uncomment the following line
// m_ProgramIsStopped is set to false in DebuggerDriver::RunQueue()
// m_ProgramIsStopped = false;
return; // come back later
}
m_QueueBusy = false;
int changeFrameAddr = 0 ;
DebuggerCmd* cmd = CurrentCommand();
if (cmd)
{
// DebugLog(wxString::Format(_T("Command parsing output (cmd: %s): %s"), cmd->m_Cmd.c_str(), buffer.Left(idx).c_str()));
RemoveTopCommand(false);
buffer.Remove(idx);
// remove the '>>>>>>' part of the prompt (or what's left of it)
int cnt = 6; // max 6 '>'
while (!buffer.empty() && buffer.Last() == _T('>') && cnt--)
buffer.RemoveLast();
if (!buffer.empty() && buffer.Last() == _T('\n'))
buffer.RemoveLast();
cmd->ParseOutput(buffer.Left(idx));
//We do NOT want default output processing for a changed frame as it can result
//in disassembly being done for a non-current location, since some of the frame
//response lines are in the pattern of breakpoint output.
GdbCmd_ChangeFrame *changeFrameCmd = dynamic_cast<GdbCmd_ChangeFrame*>(cmd);
if (changeFrameCmd)
changeFrameAddr = changeFrameCmd->AddrChgMode();
delete cmd;
RunQueue();
}
--- End code ---
If we send a string which is: disassemble 0x00401650\ninfo frame\n
Then, GDB correctly return TWO prompts. But in the above code, the sub-string before the FIRST prompt is handled, and the whole commands is removed(by the function call RemoveTopCommand(false);).
The idea to fix this is: send the two commands separately, so we will handle the returned string one by one, especially the command was removed one by one.
oBFusCATed:
This won't work. You need to create two separate command objects and then add both of them in the queue. But probably this would make the disassemble command pretty complex.
ollydbg:
--- Quote from: oBFusCATed on January 13, 2019, 10:56:41 am ---This won't work. You need to create two separate command objects and then add both of them in the queue. But probably this would make the disassemble command pretty complex.
--- End quote ---
Yes, that make things more complex.
If we want to run several GDB commands and only return one GDB prompt, I think we need this GDB User-defined commands, see here:
--- Code: ---ftp://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_188.html
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version