File: screenshot.cc

package info (click to toggle)
libcwd 1.0.4-1.1
  • links: PTS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 8,136 kB
  • ctags: 10,313
  • sloc: cpp: 23,354; sh: 9,798; ansic: 1,172; makefile: 852; exp: 234; awk: 11
file content (68 lines) | stat: -rw-r--r-- 1,701 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <libcwd/sys.h>
#include <libcwd/debug.h>
#include <libcwd/type_info.h>

#define builtin_return_address(addr) ((char*)__builtin_return_address(addr) + libcwd::builtin_return_address_offset)

template<typename T>
  class A {
    int i;
  public:
    A(void) {};
  };

template<typename T>
  class B {
    int i;
  public:
    B(void) {};
    ~B(void);
  };

template<typename T1, typename T2>
  class C : public A<T1>, public B<T2> {
    int i;
  public:
    C(void) {};
  };

template<typename T>
B<T>::~B(void)
{
  Dout(dc::notice, "Calling the destructor of " <<
                   libcwd::type_info_of(*this).demangled_name() << " (this == " << this << ")");
  libcwd::alloc_ct const* alloc = libcwd::find_alloc(this);
  if (sizeof(*this) != alloc->size())
  {
    Debug(dc::malloc.off());
    Debug(libcw_do.push_marker());
    Debug(libcw_do.marker().assign(": | "));
    Dout(dc::notice, "This is a base class of an object starting at " << alloc->start());
    Dout(dc::notice, "The type of the pointer to the allocated object is " <<
                     alloc->type_info().demangled_name());
    Debug(libcw_do.marker().assign(": ` "));
    Dout(dc::notice, "The destructor was called from " << location_ct(builtin_return_address(0)));
    Debug(dc::malloc.on());
    Debug(libcw_do.pop_marker());
  }
}

int main(void)
{
  Debug(libcw_do.on());
  Debug(dc::notice.on());
  Debug(dc::malloc.on());

  B<int>* b = new B<int>;				// line 56
  AllocTag(b, "object `b'");
  Dout(dc::notice, "b is " << b);

  C<double, B<char> >* c = new C<double, B<char> >;	// line 60
  AllocTag(c, "object `c'");
  Dout(dc::notice, "c is " << c);

  delete b;
  delete c;						// line 65

  return 0;
}