@@ -368,27 +368,10 @@ typedef struct GDBState {
368
368
gdb_syscall_complete_cb current_syscall_cb ;
369
369
GString * str_buf ;
370
370
GByteArray * mem_buf ;
371
+ int sstep_flags ;
372
+ int supported_sstep_flags ;
371
373
} GDBState ;
372
374
373
- /* By default use no IRQs and no timers while single stepping so as to
374
- * make single stepping like an ICE HW step.
375
- */
376
- static int sstep_flags = SSTEP_ENABLE |SSTEP_NOIRQ |SSTEP_NOTIMER ;
377
-
378
- /* Retrieves flags for single step mode. */
379
- static int get_sstep_flags (void )
380
- {
381
- /*
382
- * In replay mode all events written into the log should be replayed.
383
- * That is why NOIRQ flag is removed in this mode.
384
- */
385
- if (replay_mode != REPLAY_MODE_NONE ) {
386
- return SSTEP_ENABLE ;
387
- } else {
388
- return sstep_flags ;
389
- }
390
- }
391
-
392
375
static GDBState gdbserver_state ;
393
376
394
377
static void init_gdbserver_state (void )
@@ -399,6 +382,26 @@ static void init_gdbserver_state(void)
399
382
gdbserver_state .str_buf = g_string_new (NULL );
400
383
gdbserver_state .mem_buf = g_byte_array_sized_new (MAX_PACKET_LENGTH );
401
384
gdbserver_state .last_packet = g_byte_array_sized_new (MAX_PACKET_LENGTH + 4 );
385
+
386
+ /*
387
+ * In replay mode all events will come from the log and can't be
388
+ * suppressed otherwise we would break determinism. However as those
389
+ * events are tied to the number of executed instructions we won't see
390
+ * them occurring every time we single step.
391
+ */
392
+ if (replay_mode != REPLAY_MODE_NONE ) {
393
+ gdbserver_state .supported_sstep_flags = SSTEP_ENABLE ;
394
+ } else {
395
+ gdbserver_state .supported_sstep_flags =
396
+ SSTEP_ENABLE | SSTEP_NOIRQ | SSTEP_NOTIMER ;
397
+ }
398
+
399
+ /*
400
+ * By default use no IRQs and no timers while single stepping so as to
401
+ * make single stepping like an ICE HW step.
402
+ */
403
+ gdbserver_state .sstep_flags = gdbserver_state .supported_sstep_flags ;
404
+
402
405
}
403
406
404
407
#ifndef CONFIG_USER_ONLY
@@ -505,7 +508,7 @@ static int gdb_continue_partial(char *newstates)
505
508
CPU_FOREACH (cpu ) {
506
509
if (newstates [cpu -> cpu_index ] == 's' ) {
507
510
trace_gdbstub_op_stepping (cpu -> cpu_index );
508
- cpu_single_step (cpu , sstep_flags );
511
+ cpu_single_step (cpu , gdbserver_state . sstep_flags );
509
512
}
510
513
}
511
514
gdbserver_state .running_state = 1 ;
@@ -524,7 +527,7 @@ static int gdb_continue_partial(char *newstates)
524
527
break ; /* nothing to do here */
525
528
case 's' :
526
529
trace_gdbstub_op_stepping (cpu -> cpu_index );
527
- cpu_single_step (cpu , get_sstep_flags () );
530
+ cpu_single_step (cpu , gdbserver_state . sstep_flags );
528
531
cpu_resume (cpu );
529
532
flag = 1 ;
530
533
break ;
@@ -1883,7 +1886,7 @@ static void handle_step(GArray *params, void *user_ctx)
1883
1886
gdb_set_cpu_pc ((target_ulong )get_param (params , 0 )-> val_ull );
1884
1887
}
1885
1888
1886
- cpu_single_step (gdbserver_state .c_cpu , get_sstep_flags () );
1889
+ cpu_single_step (gdbserver_state .c_cpu , gdbserver_state . sstep_flags );
1887
1890
gdb_continue ();
1888
1891
}
1889
1892
@@ -2017,24 +2020,44 @@ static void handle_v_commands(GArray *params, void *user_ctx)
2017
2020
2018
2021
static void handle_query_qemu_sstepbits (GArray * params , void * user_ctx )
2019
2022
{
2020
- g_string_printf (gdbserver_state .str_buf , "ENABLE=%x,NOIRQ=%x,NOTIMER=%x" ,
2021
- SSTEP_ENABLE , SSTEP_NOIRQ , SSTEP_NOTIMER );
2023
+ g_string_printf (gdbserver_state .str_buf , "ENABLE=%x" , SSTEP_ENABLE );
2024
+
2025
+ if (gdbserver_state .supported_sstep_flags & SSTEP_NOIRQ ) {
2026
+ g_string_append_printf (gdbserver_state .str_buf , ",NOIRQ=%x" ,
2027
+ SSTEP_NOIRQ );
2028
+ }
2029
+
2030
+ if (gdbserver_state .supported_sstep_flags & SSTEP_NOTIMER ) {
2031
+ g_string_append_printf (gdbserver_state .str_buf , ",NOTIMER=%x" ,
2032
+ SSTEP_NOTIMER );
2033
+ }
2034
+
2022
2035
put_strbuf ();
2023
2036
}
2024
2037
2025
2038
static void handle_set_qemu_sstep (GArray * params , void * user_ctx )
2026
2039
{
2040
+ int new_sstep_flags ;
2041
+
2027
2042
if (!params -> len ) {
2028
2043
return ;
2029
2044
}
2030
2045
2031
- sstep_flags = get_param (params , 0 )-> val_ul ;
2046
+ new_sstep_flags = get_param (params , 0 )-> val_ul ;
2047
+
2048
+ if (new_sstep_flags & ~gdbserver_state .supported_sstep_flags ) {
2049
+ put_packet ("E22" );
2050
+ return ;
2051
+ }
2052
+
2053
+ gdbserver_state .sstep_flags = new_sstep_flags ;
2032
2054
put_packet ("OK" );
2033
2055
}
2034
2056
2035
2057
static void handle_query_qemu_sstep (GArray * params , void * user_ctx )
2036
2058
{
2037
- g_string_printf (gdbserver_state .str_buf , "0x%x" , sstep_flags );
2059
+ g_string_printf (gdbserver_state .str_buf , "0x%x" ,
2060
+ gdbserver_state .sstep_flags );
2038
2061
put_strbuf ();
2039
2062
}
2040
2063
0 commit comments