使用 Qt 5.1.1 for Windows 32 位(使用 MinGW 4.8),在调试 GDB 时希望在第一次调试代码后进入反汇编。
我做了一个“Plain C++”项目,插入一些简单的代码:
int x = 5;
cout << x << endl;
return 0;
使用第一行的断点构建和调试它。第一次通过它调试只需使用“Step Over”即可很好地单步执行代码。之后的任何调试会话,当它遇到 cout (或任何其他与库相关的内容)时,它都会进入 ntdll 的异常视图。
未检查按指令操作,并且有我的代码的调试信息。它按预期工作一次,然后拒绝。
我可以删除构建文件夹和 .pro.user 文件,并且该项目在新构建后仍然表现出相同的行为。甚至尝试擦除我的 QTProject 设置文件夹。似乎没有办法不止一次地调试我的代码,而它不想进入程序集而不是单步执行语句。如果我创建一个新项目,我可以正常调试一次,然后它开始以相同的方式运行。
寻找修复或建议尝试的事情。
有机会回去...在良好的初始运行与顺序运行上区分调试器日志。一切看起来都很相似,直到我运行良好:
=thread-exited,id="2",group-id="i1" sThread 2 in group i1 exited ~"[Switching to Thread 5588.0x239c]\n" =thread-selected,id="1" sThread 1 selected
糟糕的跑步从来没有过。后来,这是糟糕的运行所独有的:
>1272^done,threads=[{id="2",target-id="Thread 7148.0x242c",frame=
{level="0",addr="0x7792fd91",func="ntdll!RtlFindSetBits",args=
[],from="C:\\Windows\\system32\\ntdll.dll"},state="stopped"},
//LINES BELOW COMMON TO GOOD+BAD
{id="1",target-id="Thread 7148.0x1bbc",frame=
{level="0",addr="0x00401606",func="main",args=
[],file="..\\untitled8\\main.cpp",fullname=
"C:\\Users\\Andrew\\Desktop\\untitled8\\main.cpp",line="7"},
state="stopped"}],current-thread-id="1"*
然后一旦它到达断点,良好的运行就会显示:
*stopped,reason="end-stepping-range",frame={addr="0x00401620",func=" fu0 __ZSt4cout",args[], file="..\untitled8\main.cpp", fullname="C :\Users\Andrew\Desktop\untitled8\main.cpp",line="9"}, thread-id="1",stopped-threads="all"
糟糕的运行表明了这一点:
>*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint trap",
frame={addr="0x7792000d",func="ntdll!LdrFindResource_U",args=[],
from="C:\\Windows\\system32\\ntdll.dll"},thread-id="2",stopped-threads="all"
dNOTE: INFERIOR SPONTANEOUS STOP sStopped.
dState changed from InferiorRunOk(11) to InferiorStopOk(14) [master]
dSIGTRAP CONSIDERED HARMLESS. CONTINUING.
sStopped: "signal-received"
>=thread-selected,id="2"
sThread 2 selected
<1283-thread-info
>1283^done,threads=[{id="2",target-id="Thread 7148.0x242c",frame=
{level="0",addr="0x7792000d",func="ntdll!LdrFindResource_U",args=[],
from="C:\\Windows\\system32\\ntdll.dll"},state="stopped"},
{id="1",target-id="Thread 7148.0x1bbc",
frame={level="0",addr="0x756a133d",func="KERNEL32!GetPrivateProfileStructA",
args=[],from="C:\\Windows\\syswow64\\kernel32.dll"},state="stopped"}],current-thread-id="2"
<1284-stack-list-frames 0 20
>1284^done,stack=[frame={level="0",addr="0x7792000d",func="ntdll!LdrFindResource_U",
from="C:\\Windows\\system32\\ntdll.dll"},
frame={level="1",addr="0x779af926",
func="ntdll!RtlQueryTimeZoneInformation",
from="C:\\Windows\\system32\\ntdll.dll"},frame={level="2",addr="0x75f45dd1",func="??"},
frame={level="3",addr="0x00000000",func="??"}]
<1285-stack-select-frame 0
<1286disassemble 0x7791fff9,0x77920071
<1287bb options:fancy,autoderef,dyntype vars: expanded:return,local,watch,inspect typeformats: formats: watchers:
>1285^done
>&"disassemble 0x7791fff9,0x77920071\n"
>~"Dump of assembler code from 0x7791fff9 to 0x77920071:\n"
>~" 0x7791fff9 <ntdll!LdrFindResource_U+60953>:\t"
>&"Cannot access memory at address 0x7791fff9\n"
>1286^error,msg="Cannot access memory at address 0x7791fff9"
sDisassembler failed: Cannot access memory at address 0x7791fff9
看起来由于某种原因,额外的线程没有在预期时退出,并且 qtcreator/gdb 说服自己在 ntdll 中有我想停止的断点。