@@ -53,12 +53,13 @@ static int riscv_semihosting_detect_magic_sequence(struct target *target,
53
53
54
54
/* Read three uncompressed instructions:
55
55
* The previous, the current one (pointed to by PC) and the next one. */
56
+ const target_addr_t sequence_start_address = pc - 4 ;
56
57
for (int i = 0 ; i < 3 ; i ++ ) {
57
58
uint8_t buf [4 ];
58
59
59
60
/* Instruction memories may not support arbitrary read size.
60
61
* Use any size that will work. */
61
- const target_addr_t address = ( pc - 4 ) + 4 * i ;
62
+ const target_addr_t address = sequence_start_address + ( 4 * i ) ;
62
63
int result = riscv_read_by_any_size (target , address , 4 , buf );
63
64
if (result != ERROR_OK ) {
64
65
* sequence_found = false;
@@ -67,7 +68,7 @@ static int riscv_semihosting_detect_magic_sequence(struct target *target,
67
68
68
69
const uint32_t value = target_buffer_get_u32 (target , buf );
69
70
70
- LOG_TARGET_DEBUG (target , "compare 0x%08x from 0x%" PRIx64 " against 0x%08x" ,
71
+ LOG_TARGET_DEBUG (target , "compare 0x%08" PRIx32 " from 0x%" PRIx64 " against 0x%08" PRIx32 ,
71
72
value , address , magic [i ]);
72
73
if (value != magic [i ]) {
73
74
LOG_TARGET_DEBUG (target , "Not a RISC-V semihosting sequence" );
0 commit comments