summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/tools/lldb-mi/variable/main.cpp
blob: 8c79539d4d8503921222e12828b39ffd15ba2d74 (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
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
143
144
145
146
147
148
149
150
151
152
//===-- 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 <cstdint>
#include <string>

struct complex_type
{
    int i;
    struct { long l; } inner;
    complex_type *complex_ptr;
};

struct pcomplex_type : complex_type
{
    pcomplex_type(const complex_type &complx_base, const complex_type &complx_member)
        : complex_type(complx_base), complx(complx_member) { }
    complex_type complx;
    static int si;
};

int pcomplex_type::si;

struct struct_with_unions
{
    struct_with_unions(): u_i(1), u1(-1) {}
    union 
    {
        int u_i;
        int u_j;  
    };
    union 
    {
        int  u1;
        struct
        {
            short s1;
            short s2;
        };
    };
};

void
var_update_test(void)
{
    long l = 1;
    complex_type complx = { 3, { 3L }, &complx };
    complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } };
    // BP_var_update_test_init

    l = 0;
    // BP_var_update_test_l

    complx.inner.l = 2;
    // BP_var_update_test_complx

    complx_array[1].inner.l = 4;
    // BP_var_update_test_complx_array
}

void
var_list_children_test(void)
{
    complex_type complx = { 3, { 3L }, &complx };
    complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } };
    pcomplex_type pcomplx({ 6, { 6L }, &pcomplx}, { 7, { 7L }, &pcomplx});

    // BP_var_list_children_test
}

void
gdb_set_show_print_char_array_as_string_test(void)
{
    const char *cp = "\t\"hello\"\n";
    const char ca[] = "\t\"hello\"\n";
    const char16_t *u16p = u"\t\"hello\"\n";
    const char16_t u16a[] = u"\t\"hello\"\n";
    const char32_t *u32p = U"\t\"hello\"\n";
    const char32_t u32a[] = U"\t\"hello\"\n";

    const char16_t* u16p_rus = u"\\Аламо-сквер";
    const char16_t  u16a_rus[] = u"\\Бейвью";
    const char32_t* u32p_rus = U"\\Чайнатаун";
    const char32_t  u32a_rus[] = U"\\Догпатч";

    // BP_gdb_set_show_print_char_array_as_string_test
}

void
cpp_stl_types_test(void)
{
    std::string std_string = "hello";
    // BP_cpp_stl_types_test
}

void
unnamed_objects_test(void)
{
    struct_with_unions swu;
    // BP_unnamed_objects_test
}

struct not_str
{
    not_str(char _c, int _f)
        : c(_c), f(_f) { }
    char c;
    int f;
};

void
gdb_set_show_print_expand_aggregates(void)
{
    complex_type complx = { 3, { 3L }, &complx };
    complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } };
    not_str nstr('a', 0);

    // BP_gdb_set_show_print_expand_aggregates
}

void
gdb_set_show_print_aggregate_field_names(void)
{
    complex_type complx = { 3, { 3L }, &complx };
    complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } };

    // BP_gdb_set_show_print_aggregate_field_names
}

int g_MyVar = 3;
static int s_MyVar = 4;

int
main(int argc, char const *argv[])
{
    int a = 10, b = 20;
    s_MyVar = a + b;
    var_update_test();
    var_list_children_test();
    gdb_set_show_print_char_array_as_string_test();
    cpp_stl_types_test();
    unnamed_objects_test();
    gdb_set_show_print_expand_aggregates();
    gdb_set_show_print_aggregate_field_names();
    return 0; // BP_return
}