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

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 54
How to view an assembly code while debugging?
« on: May 29, 2017, 10:38:22 am »
I'm paused at the first line of main(), and opened Debug -> Debugging windows -> Disassembly, but it's empty.

When on windows, and when using mingw and gdb, is it possible to see the resulted assembly code? Or should I generate assembly listings?

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: How to view an assembly code while debugging?
« Reply #1 on: May 29, 2017, 01:02:05 pm »
Actually, even keeping the disassembly window open breaks the debugger. It like halts, I can't even stop the debugging without closing gdb.exe in the task manager. Stepping doesn't work too.
« Last Edit: May 29, 2017, 01:08:15 pm by visir »

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: How to view an assembly code while debugging?
« Reply #2 on: May 29, 2017, 01:06:16 pm »
This is what it prints in log when I open assembly window

[debug]> if 1
disassemble 0x4016b5
info frame
end
[debug] > > >

After that, it stops reacting to anything.

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1414
Re: How to view an assembly code while debugging?
« Reply #3 on: May 29, 2017, 06:24:48 pm »
have you enabled full debugger log?
Settings->Debugger->Common->Full (Debug) log ?
try again, and post the full debug log

for me the disassembly works. What codeblocks version are you using?

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: How to view an assembly code while debugging?
« Reply #4 on: May 29, 2017, 07:13:46 pm »
full debugger log enabled.
codeblocks version is 16.01 ,  "Build: Jan 25 2016, 21:19:34 - wx2.8.12 (Windows, unicode) - 32 bit". Should be the last, I downloaded it half a month or month ago.
It's 32bit codeblocks with 32bit compiler and debugger on 64bit windows, hope that's not a problem.

Here is the full log.

Code: [Select]
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:\msys64\mingw32\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:\msys64\mingw32\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...
[debug]done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.12.1
[debug]Copyright (C) 2017 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 "i686-w64-mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.12.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 intel
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[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: 2224

[debug][New Thread 2224.0x1220]
[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 2224.0x1220.
[debug]Program stopped at 0x401646.
[debug]It stopped at a breakpoint that has since been deleted.
[debug]Type "info stack" or "info registers" for more information.
[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] > > >

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1414
Re: How to view an assembly code while debugging?
« Reply #5 on: May 29, 2017, 07:38:46 pm »
Actually, even keeping the disassembly window open breaks the debugger. It like halts, I can't even stop the debugging without closing gdb.exe in the task manager. Stepping doesn't work too.
But codeblocks does not crash? You can restart the debugging session after this? Have you tried a nightly build:
http://forums.codeblocks.org/index.php/topic,21781.0.html

This looks so familiar, but i can not figure out why....

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: How to view an assembly code while debugging?
« Reply #6 on: May 29, 2017, 07:47:04 pm »
Codeblocks doesn't crash, it keeps running. In fact, it even detects when I close gdb.exe manually, the debugging buttons change to the initial state.

The button for restarting session doesn't work, all debug buttons don't react. Actually, debuggee and gdb.exe stay active after I close codeblocks. The only way to stop it is to close gdb.exe manually.

I'm going to try out nightly build now, okay, I'll report the result.

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: How to view an assembly code while debugging?
« Reply #7 on: May 29, 2017, 08:52:53 pm »
It's the same in the nightly version.

Problem probably not in that, but I'll mention it just in case. I have 3 compilers installed currently, one that is just mingw, and two that came with msys2 (32 and 64 versions). But I've set paths correctly both for compiler and for debugger, so it should work?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: How to view an assembly code while debugging?
« Reply #8 on: May 29, 2017, 09:34:43 pm »
Start gdb on the command line and see it behaves the same.
If it does you know where the problem is.
If it doesn't then it is some setup command C::B executes at the beginning of the debugging session.
<debugger plugin maintainer>
(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: 54
Re: How to view an assembly code while debugging?
« Reply #9 on: May 30, 2017, 07:29:59 am »
typing "> > >" in the msys2 terminal makes it say "Cannot enable the TUI when output is not a terminal"
typing "> > >" in the windows terminal breaks it with an exception.

typing "disassemble 0x4016b5" works in both, but in windows terminal it pauses midway with "press enter to show more"-like message.

when I paste this in the msys2 terminal:
Code: [Select]
if 1
disassemble 0x401690
info frame
end
it displays this:
Code: [Select]
(gdb) if 1
disassemble 0x401690
info frame
end > > >
and I have to press enter twice for it to work.

When I just type it in msys2 terminal, the formatting is correct.

when I paste same thing in the windows terminal, it works smoothly.
« Last Edit: May 30, 2017, 07:32:08 am by visir »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: How to view an assembly code while debugging?
« Reply #10 on: May 30, 2017, 08:28:11 am »
So does the disassemble command work in a gdb run from terminal?
<debugger plugin maintainer>
(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 BlueHazzard

  • Lives here!
  • ****
  • Posts: 1414
Re: How to view an assembly code while debugging?
« Reply #11 on: May 30, 2017, 08:45:59 am »
Quote
typing "> > >" in the msys2 terminal makes it say "Cannot enable the TUI when output is not a terminal"
the >>> are added by codeblocks to show what is coming from the debugger. You do not have to type them.

https://stackoverflow.com/questions/9970636/view-both-assembly-and-c-code

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 54
Re: How to view an assembly code while debugging?
« Reply #12 on: May 30, 2017, 09:41:11 am »
typing "disassemble 0x4016b5" works in both, but in windows terminal it pauses midway with "press enter to show more"-like message.

Can't find anything about "> > >" in that stackoverflow link.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10118
Re: How to view an assembly code while debugging?
« Reply #13 on: May 30, 2017, 09:50:29 am »
typing "disassemble 0x4016b5" works in both, but in windows terminal it pauses midway with "press enter to show more"-like message.
I'm totally confused now.
What do you mean by both here?
The original report is that disassembly doesn't show in Code::Blocks. Is this still the case?

"> > >" is something odd and it is probably causing the problem, but I'm not sure where it is coming from.
<debugger plugin maintainer>
(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: 54
Re: How to view an assembly code while debugging?
« Reply #14 on: May 30, 2017, 10:03:12 am »
I think I know where the > > > are from. They are supposed to be at the beginning of each line, but instead are shown in wrong order for some reason in codeblocks log and in msys2 terminal. There are also this thing ">>>>>>cb_gdb", it's also out of order, read full log i added previously. Not sure if this is why it breaks.



I tried "disassemble 0x4016b5" in windows terminal and in msys2 terminal, it works in both. The Debug -> Debugging windows -> Disassembly in codeblocks still doesn't work. It's possible to type my own commands in that debugging log window in codeblocks?