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
99
1010const Actions = {
1111 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 ( ) ;
2020 } ,
2121 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 ( ) ;
2424 } ,
2525 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 ( ) ;
3538 } ,
3639 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 ( ) ;
4447 } ,
4548 /**
4649 * Request relevant store information from gdb to refresh UI
4750 */
4851 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 ( ) ) ;
5053 } ,
5154 execute_console_command : function ( command ) {
5255 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 ) ;
5457 } else {
55- GdbApi . run_gdb_command ( command )
58+ GdbApi . run_gdb_command ( command ) ;
5659 }
5760 } ,
5861 clear_console : function ( ) {
59- store . set ( 'gdb_console_entries' , [ ] )
62+ store . set ( 'gdb_console_entries' , [ ] ) ;
6063 } ,
6164 add_console_entries : function ( entries , type ) {
6265 if ( ! _ . isArray ( entries ) ) {
63- entries = [ entries ]
66+ entries = [ entries ] ;
6467 }
6568
6669 const typed_entries = entries . map ( entry => {
67- return { type : type , value : entry }
68- } )
70+ return { type : type , value : entry } ;
71+ } ) ;
6972
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 ) ;
7376 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 ) ;
7578 }
7679
77- store . set ( 'gdb_console_entries' , new_entries )
80+ store . set ( 'gdb_console_entries' , new_entries ) ;
7881 } ,
7982 add_gdb_response_to_console ( mi_obj ) {
8083 if ( ! mi_obj ) {
81- return
84+ return ;
8285 }
8386 // Update status
8487 let entries = [ ] ,
85- error = false
88+ error = false ;
8689 if ( mi_obj . message ) {
8790 if ( mi_obj . message === 'error' ) {
88- error = true
91+ error = true ;
8992 } else {
90- entries . push ( mi_obj . message )
93+ entries . push ( mi_obj . message ) ;
9194 }
9295 }
9396 if ( mi_obj . payload ) {
94- const interesting_keys = [ 'msg' , 'reason' , 'signal-name' , 'signal-meaning' ]
97+ const interesting_keys = [ 'msg' , 'reason' , 'signal-name' , 'signal-meaning' ] ;
9598 for ( let k of interesting_keys ) {
9699 if ( mi_obj . payload [ k ] ) {
97- entries . push ( mi_obj . payload [ k ] )
100+ entries . push ( mi_obj . payload [ k ] ) ;
98101 }
99102 }
100103
101104 if ( mi_obj . payload . frame ) {
102105 for ( let i of [ 'file' , 'func' , 'line' , 'addr' ] ) {
103106 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 ] } ` ) ;
105108 }
106109 }
107110 }
108111 }
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 ) ;
111116 } ,
112117 toggle_modal_visibility ( ) {
113- store . set ( 'show_modal' , ! store . get ( 'show_modal' ) )
118+ store . set ( 'show_modal' , ! store . get ( 'show_modal' ) ) ;
114119 } ,
115120 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 ) ;
119124 } ,
120125 set_gdb_binary_and_arguments ( binary , args ) {
121126 // 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 ) ;
129134 } ,
130135 connect_to_gdbserver ( user_input ) {
131136 // 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 } ` ] ) ;
137142 } ,
138143 remote_connected ( ) {
139- Actions . inferior_program_paused ( )
140- let cmds = [ ]
144+ Actions . inferior_program_paused ( ) ;
145+ let cmds = [ ] ;
141146 if ( store . get ( 'auto_add_breakpoint_to_main' ) ) {
142147 Actions . add_console_entries (
143148 'Connected to remote target! Adding breakpoint to main, then continuing target execution.' ,
144149 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 ( ) ) ;
149154 } else {
150155 Actions . add_console_entries (
151156 'Connected to remote target! Add breakpoint(s), then press "continue" button (do not press "run").' ,
152157 constants . console_entry_type . GDBGUI_OUTPUT
153- )
158+ ) ;
154159 }
155- GdbApi . run_gdb_command ( cmds )
160+ GdbApi . run_gdb_command ( cmds ) ;
156161 } ,
157162 attach_to_process ( user_input ) {
158163 // 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 } ` ) ;
160165 } ,
161166 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' ) ;
164169 } ,
165170 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 ) ;
169174 } ,
170175 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 ) ;
175183 } ,
176184 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' ) ;
179187 for ( let file of cached_source_files ) {
180- file . assembly = { }
188+ file . assembly = { } ;
181189 }
182- store . set ( 'cached_source_files' , cached_source_files )
190+ store . set ( 'cached_source_files' , cached_source_files ) ;
183191 } ,
184192 update_max_lines_of_code_to_fetch ( new_value ) {
185193 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 ;
187195 }
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 ) ) ;
190198 } ,
191199 show_upgrade_modal ( ) {
192200 const body = (
@@ -197,9 +205,9 @@ const Actions = {
197205 Upgrade now
198206 </ a >
199207 </ 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 ) ;
202210 } ,
203- }
211+ } ;
204212
205- export default Actions
213+ export default Actions ;
0 commit comments