1
- import { store } from 'statorgfc'
2
- import GdbApi from './GdbApi.jsx'
3
- import SourceCode from './SourceCode.jsx'
4
- import Locals from './Locals.jsx'
5
- import Memory from './Memory.jsx'
6
- import constants from './constants.js'
7
- import React from 'react'
8
- void React // using jsx implicity uses React
1
+ import { store } from 'statorgfc' ;
2
+ import GdbApi from './GdbApi.jsx' ;
3
+ import SourceCode from './SourceCode.jsx' ;
4
+ import Locals from './Locals.jsx' ;
5
+ import Memory from './Memory.jsx' ;
6
+ import constants from './constants.js' ;
7
+ import React from 'react' ;
8
+ void React ; // using jsx implicity uses React
9
9
10
10
const Actions = {
11
11
clear_program_state : function ( ) {
12
- store . set ( 'line_of_source_to_flash' , undefined )
13
- store . set ( 'paused_on_frame' , undefined )
14
- store . set ( 'selected_frame_num' , 0 )
15
- store . set ( 'current_thread_id' , undefined )
16
- store . set ( 'stack' , [ ] )
17
- store . set ( 'threads' , [ ] )
18
- Memory . clear_cache ( )
19
- Locals . clear ( )
12
+ store . set ( 'line_of_source_to_flash' , undefined ) ;
13
+ store . set ( 'paused_on_frame' , undefined ) ;
14
+ store . set ( 'selected_frame_num' , 0 ) ;
15
+ store . set ( 'current_thread_id' , undefined ) ;
16
+ store . set ( 'stack' , [ ] ) ;
17
+ store . set ( 'threads' , [ ] ) ;
18
+ Memory . clear_cache ( ) ;
19
+ Locals . clear ( ) ;
20
20
} ,
21
21
inferior_program_running : function ( ) {
22
- store . set ( 'inferior_program' , constants . inferior_states . running )
23
- Actions . clear_program_state ( )
22
+ store . set ( 'inferior_program' , constants . inferior_states . running ) ;
23
+ Actions . clear_program_state ( ) ;
24
24
} ,
25
25
inferior_program_paused : function ( frame = { } ) {
26
- store . set ( 'inferior_program' , constants . inferior_states . paused )
27
- store . set ( 'source_code_selection_state' , constants . source_code_selection_states . PAUSED_FRAME )
28
- store . set ( 'paused_on_frame' , frame )
29
- store . set ( 'fullname_to_render' , frame . fullname )
30
- store . set ( 'line_of_source_to_flash' , parseInt ( frame . line ) )
31
- store . set ( 'current_assembly_address' , frame . addr )
32
- store . set ( 'source_code_infinite_scrolling' , false )
33
- SourceCode . make_current_line_visible ( )
34
- Actions . refresh_state_for_gdb_pause ( )
26
+ store . set ( 'inferior_program' , constants . inferior_states . paused ) ;
27
+ store . set (
28
+ 'source_code_selection_state' ,
29
+ constants . source_code_selection_states . PAUSED_FRAME
30
+ ) ;
31
+ store . set ( 'paused_on_frame' , frame ) ;
32
+ store . set ( 'fullname_to_render' , frame . fullname ) ;
33
+ store . set ( 'line_of_source_to_flash' , parseInt ( frame . line ) ) ;
34
+ store . set ( 'current_assembly_address' , frame . addr ) ;
35
+ store . set ( 'source_code_infinite_scrolling' , false ) ;
36
+ SourceCode . make_current_line_visible ( ) ;
37
+ Actions . refresh_state_for_gdb_pause ( ) ;
35
38
} ,
36
39
inferior_program_exited : function ( ) {
37
- store . set ( 'inferior_program' , constants . inferior_states . exited )
38
- store . set ( 'disassembly_for_missing_file' , [ ] )
39
- store . set ( 'root_gdb_tree_var' , null )
40
- store . set ( 'previous_register_values' , { } )
41
- store . set ( 'current_register_values' , { } )
42
- store . set ( 'inferior_pid' , null )
43
- Actions . clear_program_state ( )
40
+ store . set ( 'inferior_program' , constants . inferior_states . exited ) ;
41
+ store . set ( 'disassembly_for_missing_file' , [ ] ) ;
42
+ store . set ( 'root_gdb_tree_var' , null ) ;
43
+ store . set ( 'previous_register_values' , { } ) ;
44
+ store . set ( 'current_register_values' , { } ) ;
45
+ store . set ( 'inferior_pid' , null ) ;
46
+ Actions . clear_program_state ( ) ;
44
47
} ,
45
48
/**
46
49
* Request relevant store information from gdb to refresh UI
47
50
*/
48
51
refresh_state_for_gdb_pause : function ( ) {
49
- GdbApi . run_gdb_command ( GdbApi . _get_refresh_state_for_pause_cmds ( ) )
52
+ GdbApi . run_gdb_command ( GdbApi . _get_refresh_state_for_pause_cmds ( ) ) ;
50
53
} ,
51
54
execute_console_command : function ( command ) {
52
55
if ( store . get ( 'refresh_state_after_sending_console_command' ) ) {
53
- GdbApi . run_command_and_refresh_state ( command )
56
+ GdbApi . run_command_and_refresh_state ( command ) ;
54
57
} else {
55
- GdbApi . run_gdb_command ( command )
58
+ GdbApi . run_gdb_command ( command ) ;
56
59
}
57
60
} ,
58
61
clear_console : function ( ) {
59
- store . set ( 'gdb_console_entries' , [ ] )
62
+ store . set ( 'gdb_console_entries' , [ ] ) ;
60
63
} ,
61
64
add_console_entries : function ( entries , type ) {
62
65
if ( ! _ . isArray ( entries ) ) {
63
- entries = [ entries ]
66
+ entries = [ entries ] ;
64
67
}
65
68
66
69
const typed_entries = entries . map ( entry => {
67
- return { type : type , value : entry }
68
- } )
70
+ return { type : type , value : entry } ;
71
+ } ) ;
69
72
70
- const previous_entries = store . get ( 'gdb_console_entries' )
71
- const MAX_NUM_ENTRIES = 1000
72
- const new_entries = previous_entries . concat ( typed_entries )
73
+ const previous_entries = store . get ( 'gdb_console_entries' ) ;
74
+ const MAX_NUM_ENTRIES = 1000 ;
75
+ const new_entries = previous_entries . concat ( typed_entries ) ;
73
76
if ( new_entries . length > MAX_NUM_ENTRIES ) {
74
- new_entries . splice ( 0 , new_entries . length - MAX_NUM_ENTRIES )
77
+ new_entries . splice ( 0 , new_entries . length - MAX_NUM_ENTRIES ) ;
75
78
}
76
79
77
- store . set ( 'gdb_console_entries' , new_entries )
80
+ store . set ( 'gdb_console_entries' , new_entries ) ;
78
81
} ,
79
82
add_gdb_response_to_console ( mi_obj ) {
80
83
if ( ! mi_obj ) {
81
- return
84
+ return ;
82
85
}
83
86
// Update status
84
87
let entries = [ ] ,
85
- error = false
88
+ error = false ;
86
89
if ( mi_obj . message ) {
87
90
if ( mi_obj . message === 'error' ) {
88
- error = true
91
+ error = true ;
89
92
} else {
90
- entries . push ( mi_obj . message )
93
+ entries . push ( mi_obj . message ) ;
91
94
}
92
95
}
93
96
if ( mi_obj . payload ) {
94
- const interesting_keys = [ 'msg' , 'reason' , 'signal-name' , 'signal-meaning' ]
97
+ const interesting_keys = [ 'msg' , 'reason' , 'signal-name' , 'signal-meaning' ] ;
95
98
for ( let k of interesting_keys ) {
96
99
if ( mi_obj . payload [ k ] ) {
97
- entries . push ( mi_obj . payload [ k ] )
100
+ entries . push ( mi_obj . payload [ k ] ) ;
98
101
}
99
102
}
100
103
101
104
if ( mi_obj . payload . frame ) {
102
105
for ( let i of [ 'file' , 'func' , 'line' , 'addr' ] ) {
103
106
if ( i in mi_obj . payload . frame ) {
104
- entries . push ( `${ i } : ${ mi_obj . payload . frame [ i ] } ` )
107
+ entries . push ( `${ i } : ${ mi_obj . payload . frame [ i ] } ` ) ;
105
108
}
106
109
}
107
110
}
108
111
}
109
- let type = error ? constants . console_entry_type . STD_ERR : constants . console_entry_type . STD_OUT
110
- Actions . add_console_entries ( entries , type )
112
+ let type = error
113
+ ? constants . console_entry_type . STD_ERR
114
+ : constants . console_entry_type . STD_OUT ;
115
+ Actions . add_console_entries ( entries , type ) ;
111
116
} ,
112
117
toggle_modal_visibility ( ) {
113
- store . set ( 'show_modal' , ! store . get ( 'show_modal' ) )
118
+ store . set ( 'show_modal' , ! store . get ( 'show_modal' ) ) ;
114
119
} ,
115
120
show_modal ( header , body ) {
116
- store . set ( 'modal_header' , header )
117
- store . set ( 'modal_body' , body )
118
- store . set ( 'show_modal' , true )
121
+ store . set ( 'modal_header' , header ) ;
122
+ store . set ( 'modal_body' , body ) ;
123
+ store . set ( 'show_modal' , true ) ;
119
124
} ,
120
125
set_gdb_binary_and_arguments ( binary , args ) {
121
126
// remove list of source files associated with the loaded binary since we're loading a new one
122
- store . set ( 'source_file_paths' , [ ] )
123
- store . set ( 'language' , 'c_family' )
124
- store . set ( 'inferior_binary_path' , null )
125
- Actions . inferior_program_exited ( )
126
- let cmds = GdbApi . get_load_binary_and_arguments_cmds ( binary , args )
127
- GdbApi . run_gdb_command ( cmds )
128
- GdbApi . get_inferior_binary_last_modified_unix_sec ( binary )
127
+ store . set ( 'source_file_paths' , [ ] ) ;
128
+ store . set ( 'language' , 'c_family' ) ;
129
+ store . set ( 'inferior_binary_path' , null ) ;
130
+ Actions . inferior_program_exited ( ) ;
131
+ let cmds = GdbApi . get_load_binary_and_arguments_cmds ( binary , args ) ;
132
+ GdbApi . run_gdb_command ( cmds ) ;
133
+ GdbApi . get_inferior_binary_last_modified_unix_sec ( binary ) ;
129
134
} ,
130
135
connect_to_gdbserver ( user_input ) {
131
136
// https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Target-Manipulation.html#GDB_002fMI-Target-Manipulation
132
- store . set ( 'source_file_paths' , [ ] )
133
- store . set ( 'language' , 'c_family' )
134
- store . set ( 'inferior_binary_path' , null )
135
- Actions . inferior_program_exited ( )
136
- GdbApi . run_gdb_command ( [ `-target-select remote ${ user_input } ` ] )
137
+ store . set ( 'source_file_paths' , [ ] ) ;
138
+ store . set ( 'language' , 'c_family' ) ;
139
+ store . set ( 'inferior_binary_path' , null ) ;
140
+ Actions . inferior_program_exited ( ) ;
141
+ GdbApi . run_gdb_command ( [ `-target-select remote ${ user_input } ` ] ) ;
137
142
} ,
138
143
remote_connected ( ) {
139
- Actions . inferior_program_paused ( )
140
- let cmds = [ ]
144
+ Actions . inferior_program_paused ( ) ;
145
+ let cmds = [ ] ;
141
146
if ( store . get ( 'auto_add_breakpoint_to_main' ) ) {
142
147
Actions . add_console_entries (
143
148
'Connected to remote target! Adding breakpoint to main, then continuing target execution.' ,
144
149
constants . console_entry_type . GDBGUI_OUTPUT
145
- )
146
- cmds . push ( '-break-insert main' )
147
- cmds . push ( '-exec-continue' )
148
- cmds . push ( GdbApi . get_break_list_cmd ( ) )
150
+ ) ;
151
+ cmds . push ( '-break-insert main' ) ;
152
+ cmds . push ( '-exec-continue' ) ;
153
+ cmds . push ( GdbApi . get_break_list_cmd ( ) ) ;
149
154
} else {
150
155
Actions . add_console_entries (
151
156
'Connected to remote target! Add breakpoint(s), then press "continue" button (do not press "run").' ,
152
157
constants . console_entry_type . GDBGUI_OUTPUT
153
- )
158
+ ) ;
154
159
}
155
- GdbApi . run_gdb_command ( cmds )
160
+ GdbApi . run_gdb_command ( cmds ) ;
156
161
} ,
157
162
attach_to_process ( user_input ) {
158
163
// https://sourceware.org/gdb/onlinedocs/gdb/GDB_002fMI-Target-Manipulation.html#GDB_002fMI-Target-Manipulation
159
- GdbApi . run_gdb_command ( `-target-attach ${ user_input } ` )
164
+ GdbApi . run_gdb_command ( `-target-attach ${ user_input } ` ) ;
160
165
} ,
161
166
fetch_source_files ( ) {
162
- store . set ( 'source_file_paths' , [ ] )
163
- GdbApi . run_gdb_command ( '-file-list-exec-source-files' )
167
+ store . set ( 'source_file_paths' , [ ] ) ;
168
+ GdbApi . run_gdb_command ( '-file-list-exec-source-files' ) ;
164
169
} ,
165
170
view_file ( fullname , line ) {
166
- store . set ( 'fullname_to_render' , fullname )
167
- store . set ( 'source_code_infinite_scrolling' , false )
168
- Actions . set_line_state ( line )
171
+ store . set ( 'fullname_to_render' , fullname ) ;
172
+ store . set ( 'source_code_infinite_scrolling' , false ) ;
173
+ Actions . set_line_state ( line ) ;
169
174
} ,
170
175
set_line_state ( line ) {
171
- store . set ( 'source_code_infinite_scrolling' , false )
172
- store . set ( 'source_code_selection_state' , constants . source_code_selection_states . USER_SELECTION )
173
- store . set ( 'line_of_source_to_flash' , parseInt ( line ) )
174
- store . set ( 'make_current_line_visible' , true )
176
+ store . set ( 'source_code_infinite_scrolling' , false ) ;
177
+ store . set (
178
+ 'source_code_selection_state' ,
179
+ constants . source_code_selection_states . USER_SELECTION
180
+ ) ;
181
+ store . set ( 'line_of_source_to_flash' , parseInt ( line ) ) ;
182
+ store . set ( 'make_current_line_visible' , true ) ;
175
183
} ,
176
184
clear_cached_assembly ( ) {
177
- store . set ( 'disassembly_for_missing_file' , [ ] )
178
- let cached_source_files = store . get ( 'cached_source_files' )
185
+ store . set ( 'disassembly_for_missing_file' , [ ] ) ;
186
+ let cached_source_files = store . get ( 'cached_source_files' ) ;
179
187
for ( let file of cached_source_files ) {
180
- file . assembly = { }
188
+ file . assembly = { } ;
181
189
}
182
- store . set ( 'cached_source_files' , cached_source_files )
190
+ store . set ( 'cached_source_files' , cached_source_files ) ;
183
191
} ,
184
192
update_max_lines_of_code_to_fetch ( new_value ) {
185
193
if ( new_value <= 0 ) {
186
- new_value = constants . default_max_lines_of_code_to_fetch
194
+ new_value = constants . default_max_lines_of_code_to_fetch ;
187
195
}
188
- store . set ( 'max_lines_of_code_to_fetch' , new_value )
189
- localStorage . setItem ( 'max_lines_of_code_to_fetch' , JSON . stringify ( new_value ) )
196
+ store . set ( 'max_lines_of_code_to_fetch' , new_value ) ;
197
+ localStorage . setItem ( 'max_lines_of_code_to_fetch' , JSON . stringify ( new_value ) ) ;
190
198
} ,
191
199
show_upgrade_modal ( ) {
192
200
const body = (
@@ -197,9 +205,9 @@ const Actions = {
197
205
Upgrade now
198
206
</ a >
199
207
</ div >
200
- )
201
- Actions . show_modal ( 'upgrade to pro for this feature' , body )
208
+ ) ;
209
+ Actions . show_modal ( 'upgrade to pro for this feature' , body ) ;
202
210
} ,
203
- }
211
+ } ;
204
212
205
- export default Actions
213
+ export default Actions ;
0 commit comments