Menu

#429 debug windows 32bit program with cdb 64bit

Next_Release
applied
Patch
2016-11-09
2016-11-08
No

Codeblocks hung alway when debugged windows 32bit program with 64bit cdb. I found the reason that causes this problem by debugging: The command prompt is the form like "0:000:x86>" when debugging 32bit program with 64bit cdb, but the form codeblocks expects is like "0:000>".

1 Attachments

Discussion

  • Teodor Petrov

    Teodor Petrov - 2016-11-08
    • labels: --> Debugger, CDB
    • assigned_to: Morten MacFly --> Teodor Petrov
     
  • Teodor Petrov

    Teodor Petrov - 2016-11-08

    Good, but this patch breaks the original case when using 32bit cdb.
    Would you be kind enough to provide a patch that works in both cases?
    I'm mostly using linux, so cannot test this easily.

     
  • Debugfan Chin

    Debugfan Chin - 2016-11-09

    Thanks for replying so quick. I have tested the patched version with 64bit cdb on my windows 7 and 32bit cdb on my windows xp in virtual machine. they both work. the original regex match for cdb promt is:

    wxRegEx rePrompt(_T("([0-9]+:){1,2}[0-9]+>"))
    

    the patched version is:

    static wxRegEx rePrompt(_T("([0-9]+:){1,2}[0-9]+(:x86)?>"));
    

    the patched version matches string "x86" 0 or 1 times, so it work with 64bit, and is compatible with 32bit.
    I found another problem with cdb in the original version existed and described in the ticket #430. To make cdb work completely, I hope applying those two patches.

     
  • Teodor Petrov

    Teodor Petrov - 2016-11-09

    Can you show me some output from both versions, so I can add some tests?

    FYI: There is a separate project to create a better CDB debugger plugin. You can try it and see if it works better.

     
  • Debugfan Chin

    Debugfan Chin - 2016-11-09

    32bit cdb output is as follow:

    C:\Documents and Settings\anonymous>C:\WinDDK\7600.16385.1\Debuggers\cdb.exe -G
    -lines -2 -y C:/projects/test/; -srcpath C:/projects/test/; C:/projects/test/bin
    /Debug/test.exe
    
    Microsoft (R) Windows Debugger Version 6.12.0002.633 X86
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    CommandLine: C:/projects/test/bin/Debug/test.exe
    Symbol search path is: C:/projects/test/
    Executable search path is:
    ModLoad: 00400000 00407000   test.exe
    ModLoad: 7c920000 7c9b3000   ntdll.dll
    ModLoad: 7c800000 7c91e000   C:\WINDOWS\system32\kernel32.dll
    ModLoad: 10200000 1026c000   C:\WINDOWS\system32\MSVCRTD.dll
    ModLoad: 10480000 104fe000   C:\WINDOWS\system32\MSVCP60D.dll
    (4f8.4cc): Break instruction exception - code 80000003 (first chance)
    eax=00241eb4 ebx=7ffdf000 ecx=00000004 edx=00000010 esi=00241f48 edi=00241eb4
    eip=7c92120e esp=0012fb20 ebp=0012fc94 iopl=0         nv up ei pl nz na po nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000202
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdl
    l.dll -
    ntdll!DbgBreakPoint:
    7c92120e cc              int     3
    0:000>
    

    64bit cdb will encounter two breakpoints after load. The first is as follow:

    C:\Users\Administrator>D:\WinDDK\7600.16385.1\Debuggers\cdb.exe -G -lines -2 -y
    D:/chateau/projects/dbgtest/; -srcpath D:/chateau/projects/dbgtest/; D:/chateau/
    projects/dbgtest/bin/Debug/dbgtest.exe
    
    Microsoft (R) Windows Debugger Version 6.12.0002.633 AMD64
    Copyright (c) Microsoft Corporation. All rights reserved.
    
    CommandLine: D:/chateau/projects/dbgtest/bin/Debug/dbgtest.exe
    Symbol search path is: D:/chateau/projects/dbgtest/
    Executable search path is:
    ModLoad: 00000000`00400000 00000000`00407000   dbgtest.exe
    ModLoad: 00000000`772e0000 00000000`7748a000   ntdll.dll
    ModLoad: 00000000`774c0000 00000000`77640000   ntdll32.dll
    ModLoad: 00000000`748c0000 00000000`748ff000   C:\Windows\SYSTEM32\wow64.dll
    ModLoad: 00000000`74860000 00000000`748bc000   C:\Windows\SYSTEM32\wow64win.dll
    ModLoad: 00000000`74850000 00000000`74858000   C:\Windows\SYSTEM32\wow64cpu.dll
    (193c.2044): Break instruction exception - code 80000003 (first chance)
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdl
    l.dll -
    ntdll!CsrSetPriorityClass+0x40:
    00000000`77387800 cc              int     3
    0:000>
    

    Input command 'g' to continue. It will encounter the second breakpoint as follow:

    ModLoad: 00000000`74850000 00000000`74858000   C:\Windows\SYSTEM32\wow64cpu.dll
    (193c.2044): Break instruction exception - code 80000003 (first chance)
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdl
    l.dll -
    ntdll!CsrSetPriorityClass+0x40:
    00000000`77387800 cc              int     3
    0:000> g
    ModLoad: 00000000`77080000 00000000`7719f000   WOW64_IMAGE_SECTION
    ModLoad: 00000000`76520000 00000000`76630000   WOW64_IMAGE_SECTION
    ModLoad: 00000000`77080000 00000000`7719f000   NOT_AN_IMAGE
    ModLoad: 00000000`76f80000 00000000`7707a000   NOT_AN_IMAGE
    ModLoad: 00000000`76520000 00000000`76630000   C:\Windows\syswow64\kernel32.dll
    ModLoad: 00000000`76d40000 00000000`76d87000   C:\Windows\syswow64\KERNELBASE.dl
    l
    ModLoad: 00000000`10200000 00000000`1026c000   C:\Windows\SysWOW64\MSVCRTD.dll
    ModLoad: 00000000`10480000 00000000`104fe000   C:\Windows\SysWOW64\MSVCP60D.dll
    (193c.2044): WOW64 breakpoint - code 4000001f (first chance)
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdl
    l32.dll -
    ntdll32!LdrVerifyImageMatchesChecksum+0xf1f:
    77560e14 cc              int     3
    0:000:x86>
    

    This time causes the problem, and so the after do. The same problem has been described before in
    http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks#Use_32bit_CDB_for_32bit_programs_and_64bit_CDB_for_64bit_programs
    and http://forums.codeblocks.org/index.php?topic=19372.0.
    The compromised solution is using 32bit cdb instead of 64bit. But my 64bit debugger in WDK is used for other development, and I don't want to install 32bit instead of it. so I made the patch after found the reason that caused this problem.

     

    Last edit: Debugfan Chin 2016-11-09
  • Teodor Petrov

    Teodor Petrov - 2016-11-09
    • status: open --> applied
     
  • Teodor Petrov

    Teodor Petrov - 2016-11-09

    Applied in svn. Thanks for contribution.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.