Bug 12937 - Support optimized out / unused template methods
Summary: Support optimized out / unused template methods
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: archer
: 12383 (view as bug list)
Depends on:
Reported: 2011-06-27 16:32 UTC by Jan Kratochvil
Modified: 2013-02-22 16:05 UTC (History)
2 users (show)

See Also:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2011-06-27 16:32:21 UTC
This is more a GCC extension request but we need to formulate it first.

#include <map>
main ()
  std::map <int, int> v { std::make_pair (1, 2) };
//  v.clear ();
  return v[1];

7	  return v[1];
(gdb) p v.clear()
Cannot evaluate function -- may be inlined

after uncommenting the line in the source:

(gdb) p v.clear()
$1 = void

There should be for example some extra .text section in the separate .debug info file containing all the unused methods for a template instance.
Comment 1 Tom Tromey 2011-10-19 17:19:59 UTC
We've discussed a few ways to fix this.

One way would be to have the compiler emit the out-of-line instances
to a special section, which could then be put into the .debug file.
Then, gdb could call dlopen to map this into the inferior.

Another way would be to write a GCC plugin to transform the out-of-line
instances into Python code using gdb's Python API.  This could be done,
e.g., using David Malcolm's plugin (https://fedorahosted.org/gcc-python-plugin/)
and converting gimple to Python code.
Comment 2 Tom Tromey 2011-11-10 19:50:53 UTC
*** Bug 12383 has been marked as a duplicate of this bug. ***