T.R | Title | User | Personal Name | Date | Lines |
---|
808.1 | ... | GALVIA::STONES | Tom Stones | Mon Feb 10 1997 09:57 | 3 |
| I still have this problem with ladebug V4.0-30
Tom.
|
808.2 | This problem is not template specific | TLE::MERRITT | Steve Merritt, Ladebug Team | Tue Feb 18 1997 11:04 | 53 |
| I looked into this problem and here are some of the things I found.
The good news is that if you can get the symbolic information for the
header file to show up only once in the binary, Ladebug will allow you
to set a breakpoint at a given line in that header file. In this regard,
this problem is not template specific. Ladebug will have problems
handling any file within the binary being debugged if the symbolic
information for that file is in more than one place in the binary.
Here is the template specific problems I found. Multiple instances of
the header file are likely to be found in the binary if that header file
declares more than one template. In addition, if the member functions of
the templates are placed in a corresponding .C file, you will end up with
multiple copies of the symbolic info for the .C file as well. This may
not happen in all cases, but it happened in the examples I tried.
The other point to consider when trying to debug code in header files is
that most functions defined in header files are trival. As such, even
if the symbolic info for the file only shows up once, the functions
are likely to be optimized away. If they get optimized away, there is
minimal symbolic info available and hence you will not be able to see
whats going on inside the function from the debugger. When compiling
with -g, the user can limit optimizations by specifying -O0 (-O1 is the
default), but even this is no guarantee that a function will not be
optimized away.
All of this presents a big problem to the developer using templates.
Those developers using third party template libraries are pretty much
out of luck in trying to solve this problem. However, if the template
being debugged is one the developer can modify, then there is something
that can be tried.
I have found that if template declarations are limited to one per
header file, there is a good chance that the symbolic information for
this file will be included in the binary only once. If this doesn't
work, the second step is to move template member function definitions
to a .C file since the symbolic info for .C files is much less like to
be repeated. Obviously these suggestions will be impractical for a
large portion of our customers.
Without modifying the code, the only way to debug template member
functions is to use 'stop in <func>'. This has its limitations and
the user may still have trouble viewing whats going on because of the
multiple file problem. Ladebug commands such as 'class foo' and 'set
$overloadmenu=1' don't operate at the file level and thus offer no help
in resolving the multiple file problem.
The solution to this problem is to address the root cause, namely stop
the production of multiple instances of the same file from being output
in the symbolic information of a binary.
-Steve
|
808.3 | | ADA9X::BRETT | | Tue Feb 18 1997 15:29 | 23 |
|
> The solution to this problem is to address the root cause, namely stop
> the production of multiple instances of the same file from being output
> in the symbolic information of a binary.
Or teach ladebug how to deal with it. This goes back to a very fundamental
flaw in the design on Unix debuggers. There is NO reason in C or C++
why the following code is illegal or immoral...
#define FOO some_variable
#include "some-file.h"
#undef FOO
#define FOO some_different_variable
#include "some-file.h"
#undef FOO
and indeed I can point you to significant non-Digital C code written this way.
We need to learn to deal with it, not to sweep the problem under the "but I
don't like it when you to program that way" mat.
/Bevin
|
808.4 | | GALVIA::STONES | Tom Stones | Fri Feb 21 1997 05:20 | 3 |
| Instead of refusing to set the breakpoint, could ladebug give me the option of
setting the breakpoint at all addresses that correspond to the line I'm
interested in?
|
808.5 | | ADA9X::BRETT | | Fri Feb 21 1997 07:42 | 6 |
| I checked out Visual C++ 4.0 last night.
It sets the breakpoints in all the instances, and in all the occurrences of the
include file.
/Bevin
|
808.6 | | TLE::MURRAY | Wanfang Murray | Mon Feb 24 1997 07:16 | 9 |
|
This problem is a side-effect of mergeable and non-mergeable stuff.
So, your request is to have ladebug to set breakpoints on all
instances, right?
Will this problem be fixed with your new changes in the object
file?
Wanfang
|
808.7 | | ADA9X::BRETT | | Mon Feb 24 1997 13:15 | 30 |
| > This problem is a side-effect of mergeable and non-mergeable stuff.
Which makes ladebug think the file has been included twice when it has only
been included once, I presume?
> So, your request is to have ladebug to set breakpoints on all instances,
> right?
There is only ONE instance. I suspect ladebug is getting confused because
it believes what has happened is
one include, with one routine definition
got split into
one include, mergeable, with no routine definition
one include, non-mergeable, with one routine definition
and then ladebug looked for the file name and couldn't decide where to go,
even though only one path would have worked?
> Will this problem be fixed with your new changes in the object file?
No, since it also happens with C and my fixes are for C++. Mergeability seems
to be ok with C.
/bevin
|