Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1728320
  • 博文数量: 347
  • 博客积分: 9328
  • 博客等级: 中将
  • 技术积分: 2680
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-29 23:45
文章分类

全部博文(347)

文章存档

2016年(1)

2013年(4)

2012年(207)

2011年(85)

2010年(50)

分类: C/C++

2012-08-06 01:12:05

In another post, Steve Loughran asks "Why does the PDB format change every release? What is wrong with having one standard layout for debug symbols and leaving it alone?"

A good question, and one that I wondered about many years ago. The answer is that a symbol table has to be able to reproduce as much information about the program as reasonably possible. As languages adapt and add new functionality, it's very likely that the additions to the language or the generated code can't be faithfully reproduced by a symbol table from the preceding version's compiler.

Here's an example from a long time ago. One of Borland's symbol table formats was based on somewhat of an industry standard format. Subsequently, the compiler introduced advanced optimizations that let a local variables be stored in different locations at different point in a function's code. For instance, in the first 7 bytes of the function, 'foo' might exist at [EBP-4], for the next 12 bytes at ESI, and the next 10 bytes at EDI. There was simply no way to represent this information in the existing symbol table format. So why extend the format? Without doing so, the debugger would have no clue of where to find the correct value of the variable, and would end up giving the user incorrect information. This breaks one of the cardinal rules of debuggers. (Incidentally, these need to be written down somewhere, if they're not already. Russ?)

Another example: Consider the sea change from Visual C++ 6.0 to Visual Studio.NET. Existing debug formats had almost no support for anything like the managed world where functions are compiled at runtime.

One could make an argument that symbol tables should be extensible without breaking the existing format. Some might point to an XML representation as one such means. However, I would contend that the above example I gave is a sufficient counter-argument. It's just the nature of the game that compilers, debuggers, and symbol formats need to stay in lockstep for anything other than trivial debugging purposes.
阅读(623) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~