当前位置:网站首页>Why does the debugger display the wrong function
Why does the debugger display the wrong function
2022-07-26 01:52:00 【Topomeyer - long development road】
Sometimes you need to use debugging when solving some problems , This scene is very common , We set a breakpoint somewhere in the code , Then step into a function for single step debugging , But you will find , The debugger will show you in another function . What's the matter ? Let's take a look at the following code .

When you step to call p->GetValue() Local time of , You will find that the debugger shows that it is currently Class1::GetQ in . that , What happened ?
This is because , From the linker's perspective , In the code generation phase , The linker combines all the same functions , As shown in the figure below :

Please note that , At the object code level , These two functions are exactly the same .( Please note that , Whether the two functions are the same at the object code level depends largely on the compiler version you use and the optimization flag . When you use templates , The same code generation frequency of different functions is very high .)
therefore , Linker says :” ok , What's the point of having two identical functions ? I will only keep one copy and use it to represent Class1::GetQ and Class2::GetValue.”

Please note that , These two functions have been merged : The address of the function is the same . Just this code has two names . therefore , When the debugger sees that you have jumped to 0x010010d6 when , It doesn't know which name to use , So it just chose one of them .
That's why it looks like you skipped the wrong function .
That's what's called “ identical COMDAT Fold ”(identical COMDAT folding), You can take /OPT:NOICF Flags are passed to the linker to disable this optimization .
summary
Developing TopomelBox In the process of , One day I had a whim , Want to know the meaning of all compile switches .
Some are easy to understand , For example, various header file directories , But some linker switches are really hard to understand , Today's one ”COMDAT Folding” It's one of them .
Develop this road , It's still a long way to go .
Last
Raymond Chen Of 《The Old New Thing》 It's one of my favorite blogs , There's a lot about Windows Little knowledge , For the vast Windows For platform developers , It's really helpful .
This article is from :《Why does the debugger show me the wrong function?》
边栏推荐
- Creation and management of MySQL database and table
- Speech comprehension center comprehension summary
- flutter 下 grpc list没有Setter 方法 ,如何使用相关属性
- What is a test case? How to design?
- win下搭建嵌入式开发环境及frp穿透
- Shell summary (1)
- 【深入浅出玩转FPGA学习11----Testbench书写技巧2】
- “蔚来杯“2022牛客暑期多校训练营2 D.[Link with Game Glitch] 二分答案+SPFA判环
- CPU的三种模式
- D - Dire Wolf (interval DP)
猜你喜欢

How to use the pagoda panel to deploy the full stack project of node to the server

Cross Site Request Forgery (CSRF): impact, examples, and Prevention

Big view +500 cases, software teams should improve R & D efficiency in this way

There is no setter method in grpc list under flutter. How to use related attributes

What is cross site scripting (XSS)?

Go operation excel library excel use

Codisvsrediscluster: which cluster scheme should I choose?

What is a test case? How to design?
![[combinational logic circuit] - encoder](/img/a5/c92e0404c6a970a62595bc7a3b68cd.gif)
[combinational logic circuit] - encoder

Pt onnx ncnn conversion problem record (followed by yolov5 training)
随机推荐
保护系统日志服务器和设备
销量连连夺冠,五菱的成功秘诀只有低价吗?
Niuke - bm39 serialized binary tree [hard]
4QAM, 16QAM modulation and demodulation simulation circuit, observe and analyze QAM constellation and bit error rate curve [matlab code]
大咖观点+500强案例,软件团队应该这样提升研发效能
SVN版本控制分支、合并功能使用
G2. passable paths (hard version) (tree diameter + LCA)
G. Count the trains (thought set + two points)
登堂入室soc之编程基础环境变量设置
Is it safe to open an account for stock speculation through the online account manager?
Codisvsrediscluster: which cluster scheme should I choose?
The sales volume has won the championship repeatedly. Is the secret of Wuling's success only low price?
[Verilog digital system design (Xia Yuwen) 3 ----- basic concepts of Verilog syntax 1]
There is no setter method in grpc list under flutter. How to use related attributes
Implementation of recommendation system collaborative filtering in spark
Speech comprehension - structural analysis exercise of fragment reading
“蔚来杯“2022牛客暑期多校训练营2 I.[let fat tension] 矩阵乘法 J.[Link with Arithmetic Progression]线性回归
元素和小于等于阈值的正方形的最大边长(来源:力扣(LeetCode))
[Verilog digital system design (Xia Yuwen) 4 ----- basic concepts of Verilog syntax 2]
Guys, the flinksql datahub source table has a field timestamp 16 bits, which is written to ora