当前位置:网站首页>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?》
边栏推荐
- Guys, the flinksql datahub source table has a field timestamp 16 bits, which is written to ora
- IP address of the network
- pdf. JS introduction
- 推荐系统-协同过滤在Spark中的实现
- 餐饮连锁门店重塑增长背后的数字化转型
- Summary after reading "poor dad and rich dad"
- Redis6.x配置参数详解
- Qtreewidget dotted line setting
- Silicon Valley classroom - official account cloud on demand Silicon Valley classroom microservice project practical notes
- 登堂入室soc之编程基础环境变量设置
猜你喜欢

Typora expiration solution, what if typora can't open

D. Rating compression (thinking + double pointer)

flutter 下 grpc list没有Setter 方法 ,如何使用相关属性

Digital transformation behind the reshaping growth of catering chain stores

What is a test case? How to design?

NFT market also began to diversify

Go operation excel library excel use

How idea can quickly delete recently opened projects

言语理解-片段阅读的结构剖析练习

Pt onnx ncnn conversion problem record (followed by yolov5 training)
随机推荐
flink sql 如何配置打印insert实参日志呢
图像批处理高斯滤波降噪+峰值信噪比计算
MPLS知识点
Maximum side length of elements and squares less than or equal to the threshold (source: leetcode)
Implementation of recommendation system collaborative filtering in spark
Zhinai buys melons (DP backpack)
给RestTemplate添加拦截器记录请求响应,还需解决流只读一次的问题
劳驾问一下各位老师 oracle 到pg cdc oracle 那边字段大写 pg 这边小写 同
E. OpenStreetMap (2D monotone queue)
leetcode/只出现一次的数字
G. Count the trains (thought set + two points)
【深入浅出玩转FPGA学习11----Testbench书写技巧1】
Codisvsrediscluster: which cluster scheme should I choose?
In spark SQL, date is used to display the day of the week according to the year, month and day_ format(date,‘u‘)
NFT access tool premint was hacked and lost more than 370000 US dollars
E2. escape the maze (hard version)
【深入浅出玩转FPGA学习11----Testbench书写技巧2】
SQL injection tutorial: learn through examples
“蔚来杯“2022牛客暑期多校训练营2 I.[let fat tension] 矩阵乘法 J.[Link with Arithmetic Progression]线性回归
Understand Linglong platform unified access service from simple to deep Monet