summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/runbacktrace.cc
blob: 14ad27acc871e3f4ee2c0c034ab44b1d065a703d (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/***** Autogenerated from runbacktrace.in; changes will be overwritten *****/

#line 1 "runtimebase.in"
/*****
 * runtimebase.in
 * Andy Hammerlindl  2009/07/28
 *
 * Common declarations needed for all code-generating .in files.
 *
 *****/


#line 1 "runbacktrace.in"
/*****
 * backtrace.in
 * Andy Hammerlindl  2009/07/28
 *
 * Runtime functions for printing garbage collector backtraces.
 *
 *****/

#line 1 "runtimebase.in"
#include "stack.h"
#include "types.h"
#include "builtin.h"
#include "entry.h"
#include "errormsg.h"
#include "array.h"
#include "triple.h"
#include "callable.h"
#include "opsymbols.h"

using vm::stack;
using vm::error;
using vm::array;
using vm::read;
using vm::callable;
using types::formal;
using types::function;
using camp::triple;

#define PRIMITIVE(name,Name,asyName) using types::prim##Name;
#include <primitives.h>
#undef PRIMITIVE

void unused(void *);

namespace run {
typedef double real;

array *copyArray(array *a);
array *copyArray2(array *a);
array *copyArray3(array *a);

double *copyTripleArray2Components(array *a, size_t &N,
                                   GCPlacement placement=NoGC);
triple *copyTripleArray2C(array *a, size_t &N,
                          GCPlacement placement=NoGC);
}

function *realRealFunction();

#define CURRENTPEN processData().currentpen

#line 11 "runbacktrace.in"
// No extra code for .cc file.

// Autogenerated routines:



#ifndef NOSYM
#include "runbacktrace.symbols.h"

#endif
namespace run {
#line 16 "runbacktrace.in"
// void generate_random_backtrace();
void gen_runbacktrace0(stack *)
{
#line 17 "runbacktrace.in"
#if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE)
  GC_generate_random_backtrace();
#else
  error("generate_random_backtrace() requires ./configure --enable-gc-debug");
#endif
}

#line 25 "runbacktrace.in"
// void print_random_addresses(Int n=1);
void gen_runbacktrace1(stack *Stack)
{
  Int n=vm::pop<Int>(Stack,1);
#line 26 "runbacktrace.in"
#if defined(USEGC) && defined(GC_DEBUG) && defined(GC_BACKTRACE)
  GC_gcollect();
  for (Int i=0; i < n; ++i)
    GC_debug_print_heap_obj_proc(GC_base(GC_generate_random_valid_address()));
#else
  error("print_random_addresses() requires ./configure --enable-gc-debug");
  unused(&n); // Avoid unused variable warning message.
#endif
}

} // namespace run

namespace trans {

void gen_runbacktrace_venv(venv &ve)
{
#line 16 "runbacktrace.in"
  addFunc(ve, run::gen_runbacktrace0, primVoid(), SYM(generate_random_backtrace));
#line 25 "runbacktrace.in"
  addFunc(ve, run::gen_runbacktrace1, primVoid(), SYM(print_random_addresses), formal(primInt(), SYM(n), true, false));
}

} // namespace trans