User forums > Using Code::Blocks
Debugger plugin issue when I click the "Setp into instruction"
oBFusCATed:
1. You can easily try it, but I'm not sure it will work
2. Your link is broken. You need to add :
ollydbg:
--- Quote from: ollydbg on January 13, 2019, 03:53:40 pm ---
--- 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 ---
--- End quote ---
OK, I just tested, and it works!
Here is the patch:
--- Code: --- src/plugins/debuggergdb/gdb_commands.h | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/src/plugins/debuggergdb/gdb_commands.h b/src/plugins/debuggergdb/gdb_commands.h
index 65bc040e..8cac6dde 100644
--- a/src/plugins/debuggergdb/gdb_commands.h
+++ b/src/plugins/debuggergdb/gdb_commands.h
@@ -1496,21 +1496,16 @@ class GdbCmd_DisassemblyInit : public DebuggerCmd
m_disassemblyFlavor(disassemblyFlavor),
m_hexAddrStr(hexAddrStr)
{
- m_Cmd << _T("if 1\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("cbdisassemblyinitwithpc") ;
else
- {
- m_Cmd << _T("disassemble ") << cursor.address << _T("\n") ;
- }
+ m_Cmd << _T("cbdisassemblyinitwitharg ") << cursor.address;
}
else
- m_Cmd << _T("disassemble ") << m_hexAddrStr << _T("\n") ;
-
- m_Cmd << _T("info frame\n") << _T("end");
+ m_Cmd << _T("cbdisassemblyinitwitharg ") << m_hexAddrStr;
};
void ParseOutput(const wxString& p_output)
--- End code ---
The only thing you need is the load the custom gdb command when your start the debug session:
--- Code: ---define cbdisassemblyinitwithpc
disassemble $pc,$pc+50
info frame
end
define cbdisassemblyinitwitharg
disassemble $arg0
info frame
end
--- End code ---
For me, I have a personal gdb script file(the file will load the c++ std pretty printer, the wxWidgets' pretty printer), named "my.gdb", which will be loaded when gdb started, so just add the above scripts in the script file.
oBFusCATed:
--- Quote from: ollydbg on January 13, 2019, 04:21:47 pm ---For me, I have a personal gdb script file(the file will load the c++ std pretty printer, the wxWidgets' pretty printer), named "my.gdb", which will be loaded when gdb started, so just add the above scripts in the script file.
--- End quote ---
This won't work on users' machines. If you want to commit this you have to add a file to the installation, then add a command to load this file and then apply the above patch. Also some testing on linux is required.
ollydbg:
--- Quote from: oBFusCATed on January 13, 2019, 04:15:50 pm ---2. Your link is broken. You need to add :
--- End quote ---
I have updated the link address in the posts, thanks. It looks like the address of the ftp are not shown correctly, so I use the code field to show the raw ftp address. :)
ollydbg:
--- Quote from: oBFusCATed on January 13, 2019, 04:28:15 pm ---
--- Quote from: ollydbg on January 13, 2019, 04:21:47 pm ---For me, I have a personal gdb script file(the file will load the c++ std pretty printer, the wxWidgets' pretty printer), named "my.gdb", which will be loaded when gdb started, so just add the above scripts in the script file.
--- End quote ---
This won't work on users' machines. If you want to commit this you have to add a file to the installation, then add a command to load this file and then apply the above patch. Also some testing on linux is required.
--- End quote ---
Indeed, adding a new file, and let GDB load this file for a normal user is quite complex.
BTW: this patch works without need the extra script file.
--- Code: --- src/plugins/debuggergdb/gdb_commands.h | 11 +++--------
src/plugins/debuggergdb/gdb_driver.cpp | 5 +++++
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/plugins/debuggergdb/gdb_commands.h b/src/plugins/debuggergdb/gdb_commands.h
index 65bc040e..8cac6dde 100644
--- a/src/plugins/debuggergdb/gdb_commands.h
+++ b/src/plugins/debuggergdb/gdb_commands.h
@@ -1496,21 +1496,16 @@ class GdbCmd_DisassemblyInit : public DebuggerCmd
m_disassemblyFlavor(disassemblyFlavor),
m_hexAddrStr(hexAddrStr)
{
- m_Cmd << _T("if 1\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("cbdisassemblyinitwithpc") ;
else
- {
- m_Cmd << _T("disassemble ") << cursor.address << _T("\n") ;
- }
+ m_Cmd << _T("cbdisassemblyinitwitharg ") << cursor.address;
}
else
- m_Cmd << _T("disassemble ") << m_hexAddrStr << _T("\n") ;
-
- m_Cmd << _T("info frame\n") << _T("end");
+ m_Cmd << _T("cbdisassemblyinitwitharg ") << m_hexAddrStr;
};
void ParseOutput(const wxString& p_output)
diff --git a/src/plugins/debuggergdb/gdb_driver.cpp b/src/plugins/debuggergdb/gdb_driver.cpp
index 79d22b0f..e77d36a4 100644
--- a/src/plugins/debuggergdb/gdb_driver.cpp
+++ b/src/plugins/debuggergdb/gdb_driver.cpp
@@ -142,6 +142,11 @@ void GDB_driver::Prepare(bool isConsole, int printElements)
// debugger version
QueueCommand(new DebuggerCmd(this, _T("show version")));
+
+ QueueCommand(new DebuggerCmd(this, _T("define cbdisassemblyinitwithpc\ndisassemble $pc,$pc+50\ninfo frame\nend\n")));
+
+ QueueCommand(new DebuggerCmd(this, _T("define cbdisassemblyinitwitharg\ndisassemble $arg0\ninfo frame\nend\n")));
+
// no confirmation
QueueCommand(new DebuggerCmd(this, _T("set confirm off")));
// no wrapping lines
--- End code ---
Note: if I don't add the "\n" in the end of the long new QueueCommand command string, I have the same issue as my original post, which means for GDB prompt to return, we need an extra "\n"?
So, for our old way, we only need an ending "\n" char? I haven't tested yet.
--- Code: ---if 1
disassemble 0x00401650
info frame
end
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version