Author Topic: How to view an assembly code while debugging?  (Read 12793 times)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: How to view an assembly code while debugging?
« Reply #15 on: May 30, 2017, 10:44:00 am »
It's possible to type my own commands in that debugging log window in codeblocks?
Yes it is possible after the debugger stopped, you can enter commands in the text field below the log.

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: How to view an assembly code while debugging?
« Reply #16 on: May 30, 2017, 10:54:14 am »
Okay, so I'm typing this in codeblocks log now.

This works:
Code
disassemble 0x401690

This also works:
Code
info frame

This doesn't:
Code
if 1
disassemble 0x401690
info frame
end

It's like "end" doesn't work, it never gets out of that if.

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: How to view an assembly code while debugging?
« Reply #17 on: May 30, 2017, 11:04:39 am »
Anybody knows why I can't send an empty line to the debugger? I feel like I only need to press enter one extra time for it to work, but interface just wouldn't let me.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to view an assembly code while debugging?
« Reply #18 on: May 30, 2017, 08:25:53 pm »
Because empty lines repeat the last command and doesn't make much sense.
Does the complex sequence of commands work when running from terminal?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: How to view an assembly code while debugging?
« Reply #19 on: May 30, 2017, 09:07:12 pm »
Yes, though I have to press enter twice for some reason. I actually already said this in Reply #9.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to view an assembly code while debugging?
« Reply #20 on: May 30, 2017, 09:36:34 pm »
Hm, annoying...

Can you try some older gdb?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: How to view an assembly code while debugging?
« Reply #21 on: May 30, 2017, 09:50:58 pm »
huh, with gdb 7.6.1 it actually works fine.

I can use this one for now, awesome. I can start actually working now. Getting new version to work would be good too, if you need to check something, I'm still around.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to view an assembly code while debugging?
« Reply #22 on: May 30, 2017, 11:18:20 pm »
Can you show the same log from the working version?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: How to view an assembly code while debugging?
« Reply #23 on: May 31, 2017, 08:09:29 am »
Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Users\User\Downloads\_codeblocks\hello world\
Adding source dir: C:\Users\User\Downloads\_codeblocks\hello world\
Adding file: C:\Users\User\Downloads\_codeblocks\hello world\bin\Debug\hello world.exe
Changing directory to: "C:/Users/User/Downloads/_codeblocks/hello world/."
Set variable: PATH=.;C:\msys64\mingw32\bin;C:\msys64\mingw32;C:\Program Files\Microsoft MPI\Bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Git\cmd;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;C:\Program Files (x86)\Skype\Phone;C:\Go\bin;C:\LLVM\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\TortoiseHg;C:\Program Files\doxygen\bin;D:\games\UltimateSSDKv3\Source Engine 2009\ep2\..\bin;C:\Program Files (x86)\Graphviz2.38\bin;C:\shared\my_programs\Console2;C:\shared\my_programs\mygothings\bin

[debug]Command-line: C:\MinGW\bin\gdb.exe -nx -fullname -quiet  -args "C:/Users/User/Downloads/_codeblocks/hello world/bin/Debug/hello world.exe"
[debug]Working dir : C:\Users\User\Downloads\_codeblocks\hello world

Starting debugger: C:\MinGW\bin\gdb.exe -nx -fullname -quiet  -args "C:/Users/User/Downloads/_codeblocks/hello world/bin/Debug/hello world.exe"
done

[debug]> set prompt >>>>>>cb_gdb:

Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints

[debug]Reading symbols from C:\Users\User\Downloads\_codeblocks\hello world\bin\Debug\hello world.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.6.1
[debug]Copyright (C) 2013 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "mingw32".
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.6.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Function "__cxa_throw" not defined.
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> source C:\Program Files (x86)\CodeBlocks\share\codeblocks/scripts/stl-views-1.0.3.gdb
[debug]>>>>>>cb_gdb:
[debug]> directory "C:/Users/User/Downloads/_codeblocks/hello world/"
[debug]Source directories searched: C:/Users/User/Downloads/_codeblocks/hello world;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> start
[debug]Temporary breakpoint 2 at 0x401646: file C:\Users\User\Downloads\_codeblocks\hello world\main.cpp, line 7.
[debug]Starting program: C:/Users/User/Downloads/_codeblocks/hello world/bin/Debug/hello world.exe

Child process PID: 3492

[debug][New Thread 3492.0x1318]
[debug]Temporary breakpoint 2, main () at C:\Users\User\Downloads\_codeblocks\hello world\main.cpp:7
[debug]C:\Users\User\Downloads\_codeblocks\hello world\main.cpp:7:62:beg:0x401646
[debug]>>>>>>cb_gdb:

At C:\Users\User\Downloads\_codeblocks\hello world\main.cpp:7

[debug]> info program
[debug] Using the running image of child Thread 3492.0x1318.
[debug]Program stopped at 0x401646.
[debug]It stopped at a breakpoint that has since been deleted.
[debug]>>>>>>cb_gdb:
[debug]> next
[debug]C:\Users\User\Downloads\_codeblocks\hello world\main.cpp:8:99:beg:0x40166b
[debug]>>>>>>cb_gdb:

At C:\Users\User\Downloads\_codeblocks\hello world\main.cpp:8

[debug]> next
[debug]C:\Users\User\Downloads\_codeblocks\hello world\main.cpp:9:136:beg:0x401690
[debug]>>>>>>cb_gdb:

At C:\Users\User\Downloads\_codeblocks\hello world\main.cpp:9

[debug]> if 1
disassemble 0x401690
info frame
end
[debug] > > >Dump of assembler code for function _fu1___ZSt4cout:
[debug]   0x00401676 <+0>: add    %ch,-0x10(%edx)
[debug]   0x00401679 <+3>: outsl  %ds:(%esi),(%dx)
[debug]   0x0040167a <+4>: call   0x401744 <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]   0x0040167f <+9>: movl   $0x40174c,(%esp)
[debug]   0x00401686 <+16>: mov    %eax,%ecx
[debug]   0x00401688 <+18>: call   0x401764 <std::ostream::operator<<(std::ostream& (*)(std::ostream&))>
[debug]   0x0040168d <+23>: sub    $0x4,%esp
[debug]=> 0x00401690 <+26>: movl   $0x404065,0x4(%esp)
[debug]   0x00401698 <+34>: movl   $0x6ff06a00,(%esp)
[debug]End of assembler dump.
[debug]Stack level 0, frame at 0x28fed0:
[debug] eip = 0x401690 in main (C:\Users\User\Downloads\_codeblocks\hello world\main.cpp:9); saved eip 0x4013e3
[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:
[debug]> disassemble 0x00401690
[debug]Dump of assembler code for function _fu1___ZSt4cout:
[debug]   0x00401676 <+0>: add    %ch,-0x10(%edx)
[debug]   0x00401679 <+3>: outsl  %ds:(%esi),(%dx)
[debug]   0x0040167a <+4>: call   0x401744 <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]   0x0040167f <+9>: movl   $0x40174c,(%esp)
[debug]   0x00401686 <+16>: mov    %eax,%ecx
[debug]   0x00401688 <+18>: call   0x401764 <std::ostream::operator<<(std::ostream& (*)(std::ostream&))>
[debug]   0x0040168d <+23>: sub    $0x4,%esp
[debug]=> 0x00401690 <+26>: movl   $0x404065,0x4(%esp)
[debug]   0x00401698 <+34>: movl   $0x6ff06a00,(%esp)
[debug]End of assembler dump.
[debug]>>>>>>cb_gdb: