aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/tools/lldb-mi/stack/main.cpp
blob: 32db32d2fd16623b762efd1067417ec7d148e081 (plain) (blame)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//===-- main.cpp ------------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include <exception>

struct inner
{
    int var_d;
};

struct my_type
{
    int var_a;
    char var_b;
    struct inner inner_;
};

int
local_int_test(void)
{
    int a = 10, b = 20;
    return 0; // BP_local_int_test
}

int
local_int_test_with_args(int c, int d)
{
    int a = 10, b = 20;
    return 0; // BP_local_int_test_with_args
}

int
local_struct_test(void)
{
    struct my_type var_c;
    var_c.var_a = 10;
    var_c.var_b = 'a';
    var_c.inner_.var_d = 30;
    return 0; // BP_local_struct_test
}

int local_struct_test_with_args(struct my_type var_e)
{
    struct my_type var_c;
    var_c.var_a = 10;
    var_c.var_b = 'a';
    var_c.inner_.var_d = 30;
    return 0; // BP_local_struct_test_with_args
}

int
local_array_test(void)
{
    int array[3];
    array[0] = 100;
    array[1] = 200;
    array[2] = 300;
    return 0; // BP_local_array_test
}

int
local_array_test_with_args(int* other_array)
{
    int array[3];
    array[0] = 100;
    array[1] = 200;
    array[2] = 300;
    return 0; // BP_local_array_test_with_args
}

int
local_pointer_test(void)
{
    const char *test_str = "Rakaposhi";
    int var_e = 24;
    int *ptr = &var_e;
    return 0; // BP_local_pointer_test
}

int
local_pointer_test_with_args(const char *arg_str, int *arg_ptr)
{
    const char *test_str = "Rakaposhi";
    int var_e = 24;
    int *ptr = &var_e;
    return 0; // BP_local_pointer_test_with_args
}

int do_tests_with_args()
{
    local_int_test_with_args(30, 40);

    struct my_type var_e;
    var_e.var_a = 20;
    var_e.var_b = 'b';
    var_e.inner_.var_d = 40;
    local_struct_test_with_args(var_e);

    int array[3];
    array[0] = 400;
    array[1] = 500;
    array[2] = 600;
    local_array_test_with_args(array);

    const char *test_str = "String";
    int var_z = 25;
    int *ptr = &var_z;
    local_pointer_test_with_args(test_str, ptr);

    return 0;
}

void catch_unnamed_test()
{
    try
    {
        int i = 1, j = 2;
        throw std::exception(); // BP_catch_unnamed
    }
    catch(std::exception&)
    {
    }
}

int
main(int argc, char const *argv[])
{
    local_int_test();
    local_struct_test();
    local_array_test();
    local_pointer_test();
    catch_unnamed_test();

    do_tests_with_args();
    return 0;
}