This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Implementing an O-O view of the stack code; C, C++, ...
- From: Andrew Cagney <cagney at gnu dot org>
- To: gdb at sourceware dot org
- Date: Wed, 16 Jul 2008 10:24:47 -0400
- Subject: Implementing an O-O view of the stack code; C, C++, ...
As a way of, perhaps, making the C++ or O-O discussion a little more
concrete, I'd like to consider GDB's unwinder. Here's a very abstract
depiction of the current design:
StackFactory
.
. (uses or creates)
.
Frame
|
+ SignalFrame
+ DummyFrame
+ DwarfFrame
+ ...
and here's a possible transformation that adds virtual frames:
Frame
|
.------------------+--------------.
| |
FrameDecorator AbiFrame
| |
VirtualFrame +-- SignalFrame
+-- DummyFrame
+-- DwarfFrame
(Virtual inlined instances would refer to or "decorate" an ABI frame;
and both virtual and abi frame chains would be available. A
VirtualFrame's is-signal method, for instance, could return the
decorated AbiFrame's is-signal method.)
The implementation of this would involve both virtual methods and simple
inheritance.
Perhaps the proponents of each language - C (?), C++ (Tom?) (even Ada?
Robert?) - would be interested in posting stubbed code illustrating how
this can be implemented so we can better consider the pros and cons.
As a starting point, here's some [buggy] pseudo code:
class Frame
abstract Frame getOuter();
abstract boolean isSignal();
...
class FrameDecorator extends Frame
private Frame decorated;
FrameDecorator(Frame decorated) {
this.decorated = decorated;
}
boolean isSignal() {
return this.decorated.isSignal();
class VirtualFrame extends FrameDecorator
private Frame outer;
Frame getOuter() {
if (outer != null)
return outer;
else
outerAbi = "decorated/abi".getOuter();
... construct the inline frames ...
return outerVirtual;
class AbiFrame extends Frame
private Frame outer;
Frame getOuter() {
if (outer == null)
return outer;
else
... choose outer using sniffer ...
return outer;
}
class SignalFrame extends AbiFrame
boolean isSignal() {
return true;
}