drsyms: expose type information for symbols, particularly things like argument types and sizes
From rnk@google.com on November 11, 2011 11:26:20
Our use case in DrMemory is that we have an application that creates overloads for strlen(wchar_t ) as well as other str routines to call wcslen on Windows. DrM gets horribly confused when it tries to intercept these string routines, because it assumes they take char*s. https://code.google.com/p/drmemory/issues/detail?id=682 We could attempt to get the type info from the mangled names, but I don't think it will always be there. For example, we could have the following: static size_t strlen(wchar_t *s) { return wcslen(s); }
I think this is valid C++. It creates an overload for strlen(wchar_t*), but it's static, meaning TU-private, so the compiler is not obligated to emit a decorated name. It can use whatever name it feels like, and this is the problem we had implementing issue #588 (closed) . Public syms are decorated, but private syms are not. Therefore, it may be more reliable to rely on the type information present in full PDBs (ie not stripped to public syms only).
There's a good article here on how to get type info out of dbghelp: http://www.debuginfo.com/articles/dbghelptypeinfo.html Both Windows and Linux seem to have similar models for debug info. You start by looking up a symbol and getting some cursor, which is a offset into some binary tag soup. You query it with the debug info routines, which give you more cursors to other tags with more attributes. Eventually, after you sift through function types and typedefs and things, you can get down to a base type with a canonical name and size.
Original issue: http://code.google.com/p/dynamorio/issues/detail?id=605