fbdbg  3.0
FreeBASIC Debugger
testing.bas
1 
2 '' This is how to include SUBs / FUNCTIONs / EXTERNs from the core part
3 '#INCLUDE ONCE "core/core.bi"
4 
5 '' and here we test SUBs / FUNCTIONs calls from the core part
6 'core1_sub(__FILE__)
7 '?"==> result: " ;core2_func(__FILE__)
8 
9 
10 ' here's how to set the texts in the watch bar
11 WITH GUI
12  gtk_label_set_text(GTK_LABEL(.watch1), "< empty >")
13  gtk_label_set_text(GTK_LABEL(.watch2), "< empty >")
14  gtk_label_set_text(GTK_LABEL(.watch3), "< empty >")
15  gtk_label_set_text(GTK_LABEL(.watch4), "< empty >")
16 END WITH
17 
18 
19 'set a text in current line area
20 'gtk_text_buffer_set_text(GTK_TEXT_BUFFER(SRC->BuffCur), "test", -1)
21 
22 ' here's an example on how to populate tree stores
23 'SCOPE
24  'DIM AS ZSTRING PTR entries(...) = { _ ' some rows data
25  '@"Globals(shared/common in : main" _
26  ', @"NS : TESTNAMES.XX < Shared / Integer >" _
27  ', @"VENUM <Shared /EENMU>=0 >> Unknowm" _
28  ', @"PUDT1 <Shared / * UDT>=0" _
29  ', @"ThID=3012 main:Integer" _
30  ', @"__FB_ARGC__ <Byval param / Long>=0" _
31  ', @"__FB_ARGV__ <Byval param / Long>=0" _
32  '}
33 
34  'DIM AS GtkTreeIter iter(1) ' iterators, two levels here
35  'DIM AS GObject PTR stores(...) = { _ ' all stores we populate
36  'GUI.tstoreProcVar _
37  ', GUI.tstoreProcs _
38  ', GUI.tstoreThreads _
39  ', GUI.tstoreWatch _
40  '}
41 
42  'FOR i AS INTEGER = 0 TO UBOUND(stores)
43  'VAR store = GTK_TREE_STORE(stores(i))
44  'gtk_tree_store_clear(store) ' empty the store
45 
46  'gtk_tree_store_append(store, @iter(0), NULL) ' level 0
47  'gtk_tree_store_set(store, @iter(0), 0, entries(0), -1)
48 
49  'gtk_tree_store_append(store, @iter(1), @iter(0)) ' level 1
50  'gtk_tree_store_set(store, @iter(1), 0, entries(1), -1)
51 
52  'gtk_tree_store_append(store, @iter(1), @iter(0)) ' level 1
53  'gtk_tree_store_set(store, @iter(1), 0, entries(2), -1)
54 
55  'gtk_tree_store_append(store, @iter(1), @iter(0)) ' level 1
56  'gtk_tree_store_set(store, @iter(1), 0, entries(3), -1)
57 
58  'gtk_tree_store_append(store, @iter(0), NULL) ' level 0
59  'gtk_tree_store_set(store, @iter(0), 0, entries(4), -1)
60 
61  'gtk_tree_store_append(store, @iter(1), @iter(0)) ' level 1
62  'gtk_tree_store_set(store, @iter(1), 0, entries(5), -1)
63 
64  'gtk_tree_store_append(store, @iter(1), @iter(0)) ' level 1
65  'gtk_tree_store_set(store, @iter(1), 0, entries(6), -1)
66  'NEXT
67 
68 
69  '' GtkTreeViews are collapsed by default.
70 
71  '' example: expand all sublevels of the tree view
72  'gtk_tree_view_expand_all(GTK_TREE_VIEW(GUI.tviewProcVar))
73  'gtk_tree_view_expand_all(GTK_TREE_VIEW(GUI.tviewProcs))
74 
75  '' example: expand to a certain row of the tree view
76  'VAR path = gtk_tree_path_new_from_string("0:2")
77  'gtk_tree_view_expand_to_path(GTK_TREE_VIEW(GUI.tviewWatch), path)
78  'gtk_tree_path_free(path)
79 
80  'VAR model = GTK_TREE_MODEL(stores(1))
81  'VAR store = GTK_TREE_STORE(stores(1))
82 
83  'gtk_tree_model_get_iter_from_string(model, @iter(0), "0:1")
84  'gtk_tree_store_set(store, @iter(0), 1, TRUE, -1)
85 
86  'gtk_tree_model_get_iter_from_string(model, @iter(0), "1")
87  'gtk_tree_store_set(store, @iter(0), 1, TRUE, -1)
88 
89  'gtk_tree_model_get_iter_from_string(model, @iter(0), "1:0")
90  'gtk_tree_store_set(store, @iter(0), 1, TRUE, -1)
91 'END SCOPE
92 
93 
94 ' here's an example on how to populate the list store(Memory dump)
95 
96 
104 'SUB list_column_visible CDECL(BYVAL P AS gpointer, BYVAL D AS gpointer)
105  'DIM AS gint i
106  'g_object_get(P, "sort-column-id", @i, NULL)
107  'g_object_set(P, "visible", IIF(i <= D, TRUE, FALSE), NULL)
108 'END SUB
109 
110 'SCOPE
111  '' choose visible columns
112  'VAR list = gtk_tree_view_get_columns(GTK_TREE_VIEW(GUI.lviewMemory))
113  'g_list_foreach(list, @list_column_visible, CAST(gpointer, 8)) ' <= no of columns (1 to 16)
114  'g_list_free(list)
115 
116  '' populate the list store
117  'VAR store = GTK_LIST_STORE(GUI.lstoreMemory)
118  'gtk_list_store_clear(store) ' empty the store
119  'DIM AS GtkTreeIter iter ' one iterator, list store has one level
120  'FOR r AS LONG = 0 TO 15 ' all rows
121  'VAR t = r * 16
122 
123  'gtk_list_store_append(store, @iter)
124  'gtk_list_store_set(store, @iter _
125  ', 0, STR(r) _ ' column 0=index, only once if index doesn't change
126  ', 1, HEX(t) _ ' cloumn 1
127  ', 2, HEX(t + 1) _ ' cloumn 2
128  ', 3, HEX(t + 2) _' ...
129  ', 4, HEX(t + 3) _
130  ', 5, HEX(t + 4) _
131  ', 6, HEX(t + 5) _
132  ', 7, HEX(t + 6) _
133  ', 8, HEX(t + 7) _
134  ', -1) ' parameter list terminator
135  'NEXT
136 'END SCOPE
137 
138 ' here's an example for a non-modal message dialog (like accesviol.jpg)
139 SUB access_viol( _
140  BYVAL Adr AS gint _
141  , BYVAL Fnam AS ZSTRING PTR _
142  , BYVAL Proc AS ZSTRING PTR _
143  , BYVAL Lin_ AS gint _
144  , BYVAL Text AS ZSTRING PTR _
145  )
146 
147  VAR dia = gtk_message_dialog_new_with_markup(GTK_WINDOW(GUI.window1) _
148  , GTK_DIALOG_MODAL OR GTK_DIALOG_DESTROY_WITH_PARENT _
149  , GTK_MESSAGE_WARNING _
150  , GTK_BUTTONS_YES_NO _
151  , ( _
152  *__(!"TRYING TO WRITE AT ADR: <b>%d</b>\n") _
153  & *__(!"Possible error on this line but not SURE\n\n") _
154  & *__(!"<i>File</i>: <b>%s</b>\n") _
155  & *__(!"<i>Proc</i>: <b>%s</b>\n") _
156  & *__(!"<i>Line</i>: <b>%d</b> (selected and put in red)\n") _
157  & *__(!"<b>%s</b>\n\n") _
158  & *__(!"Try to continue ? (if yes change value and/or use [M]odify execution)\n") _
159  ) _
160  , Adr _
161  , Fnam _
162  , Proc _
163  , Lin_ _
164  , Text _
165  , NULL)
166 
167  IF GTK_RESPONSE_YES = gtk_dialog_run(GTK_DIALOG(dia)) THEN
168  ?*__("==> YES selected")
169  ELSE
170  ?*__("==> NO selected")
171  END IF
172  gtk_widget_destroy(dia)
173 END SUB
174