blob: 7f025bb908e2ae39e611104e3ab73cfbe34a6225 (
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
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Routines useful when debugging the Rust runtime.
#ifndef RUST_DEBUG_H
#define RUST_DEBUG_H
#include <map>
#include <string>
#include <cstdlib>
#ifndef _WIN32
#include <signal.h>
#define BREAKPOINT_AWESOME \
do { \
signal(SIGTRAP, SIG_IGN); \
raise(SIGTRAP); \
} while (0)
#else
#define BREAKPOINT_AWESOME
#endif
struct rust_task;
namespace debug {
class flag {
private:
const char *name;
bool valid;
bool value;
public:
flag(const char *in_name) : name(in_name), valid(false) {}
bool operator*() {
// FIXME (#2689): We ought to lock this.
if (!valid) {
char *ev = getenv(name);
value = ev && ev[0] != '\0' && ev[0] != '0';
valid = true;
}
return value;
}
};
class task_debug_info {
public:
std::map<void *,std::string> origins;
};
std::string backtrace();
void maybe_track_origin(rust_task *task, void *ptr);
void maybe_untrack_origin(rust_task *task, void *ptr);
// This function is intended to be called by the debugger.
void dump_origin(rust_task *task, void *ptr);
} // end namespace debug
#endif
|