]> git.cworth.org Git - vogl/blob - src/libbacktrace_test/libbacktrace_test.cpp
Initial vogl checkin
[vogl] / src / libbacktrace_test / libbacktrace_test.cpp
1 /**************************************************************************
2  *
3  * Copyright 2013-2014 RAD Game Tools and Valve Software
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26 /*
27  * libbacktrace_test.cpp
28  */
29 #include <stdio.h>
30 #include "btrace.h"
31 #include "vogl_core.h"
32 #include "vogl_json.h"
33
34 namespace blahnamespace
35 {
36     class blah
37     {
38     public:
39         blah() { }
40         ~blah() { }
41         void foobar(int x, const char *y, double z);
42         inline void foobar2()
43         {
44             foobar(0, "", 0.0);
45         }
46     };
47
48     void blah::foobar(int x, const char *y, double z)
49     {
50         VOGL_NOTE_UNUSED(x);
51         VOGL_NOTE_UNUSED(y);
52         VOGL_NOTE_UNUSED(z);
53
54         btrace_dump();
55
56         const char *calling_module = btrace_get_calling_module();
57         const char *current_module = btrace_get_current_module();
58
59         printf("\nbtrace_get_calling_module returns: %s\n", calling_module ? calling_module : "??");
60         printf("\nbtrace_get_current_module returns: %s\n", current_module ? current_module : "??");
61     }
62 }
63
64 void foo()
65 {
66     blahnamespace::blah b;
67
68     b.foobar2();
69 }
70
71 typedef void (PFN)(void);
72 extern int yyy(PFN *pfn);
73
74 inline void foo_inlined()
75 {
76     yyy(foo);
77 }
78
79 int foo_static()
80 {
81     foo_inlined();
82     return 0;
83 }
84
85 int main(int argc, char *argv[])
86 {
87     VOGL_NOTE_UNUSED(argc);
88     VOGL_NOTE_UNUSED(argv);
89   
90     printf("libbacktrace_test: hello world!\n\n");
91
92     foo_static();
93
94     printf("\n");
95
96     // Update btrace with our gl info.
97     btrace_get_glinfo().version_str = "version string here";
98     btrace_get_glinfo().glsl_version_str = "glsl version 4 billion";
99     btrace_get_glinfo().vendor_str = "vendor";
100     btrace_get_glinfo().renderer_str = "renderer_str";
101
102     vogl::json_document cur_doc;
103     btrace_get_machine_info(cur_doc.get_root());
104     cur_doc.print(true, 0, 0);
105 }