@@ -17,8 +17,6 @@ int riscv_program_lal(struct riscv_program *p, enum gdb_regno d, riscv_addr_t ad
1717/* Program interface. */
1818int riscv_program_init (struct riscv_program * p , struct target * target )
1919{
20- LOG_DEBUG ("riscv_program_init: p=%p" , p );
21-
2220 memset (p , 0 , sizeof (* p ));
2321 p -> target = target ;
2422 p -> instruction_count = 0 ;
@@ -72,14 +70,19 @@ int riscv_program_exec(struct riscv_program *p, struct target *t)
7270 return ERROR_FAIL ;
7371 }
7472
75- for (size_t i = 0 ; i < riscv_debug_buffer_size (p -> target ); ++ i ) {
76- LOG_DEBUG ("Executing program %p: debug_buffer[%02x] = DASM(0x%08lx)" , p , (int )i , (long )p -> debug_buffer [i ]);
77- if (i <= p -> instruction_count || i >= riscv_debug_buffer_size (p -> target ) - p -> data_count )
73+ for (unsigned i = 0 ; i < riscv_debug_buffer_size (p -> target ); ++ i ) {
74+ if (i < p -> instruction_count ) {
75+ LOG_DEBUG ("%p: debug_buffer[%02x] = DASM(0x%08x)" , p , i , p -> debug_buffer [i ]);
76+ riscv_write_debug_buffer (t , i , p -> debug_buffer [i ]);
77+ }
78+ if (i >= riscv_debug_buffer_size (p -> target ) - p -> data_count ) {
79+ LOG_DEBUG ("%p: debug_buffer[%02x] = 0x%08x" , p , i , p -> debug_buffer [i ]);
7880 riscv_write_debug_buffer (t , i , p -> debug_buffer [i ]);
81+ }
7982 }
8083
8184 if (riscv_execute_debug_buffer (t ) != ERROR_OK ) {
82- LOG_DEBUG ("Unable to execute program %p" , p );
85+ LOG_ERROR ("Unable to execute program %p" , p );
8386 return ERROR_FAIL ;
8487 }
8588
@@ -96,8 +99,6 @@ int riscv_program_exec(struct riscv_program *p, struct target *t)
9699
97100riscv_addr_t riscv_program_alloc_data (struct riscv_program * p , size_t bytes )
98101{
99- LOG_DEBUG ("allocating %d bytes of data" , (int )bytes );
100-
101102 riscv_addr_t addr =
102103 riscv_debug_buffer_addr (p -> target )
103104 + riscv_debug_buffer_size (p -> target ) * sizeof (p -> debug_buffer [0 ])
@@ -110,11 +111,10 @@ riscv_addr_t riscv_program_alloc_data(struct riscv_program *p, size_t bytes)
110111 + p -> instruction_count * sizeof (p -> debug_buffer [0 ]);
111112
112113 if (addr <= ptop ) {
113- LOG_DEBUG ("unable to allocate %d bytes" , (int )bytes );
114+ LOG_ERROR ("unable to allocate %d bytes" , (int )bytes );
114115 return RISCV_PROGRAM_ALLOC_FAIL ;
115116 }
116117
117- LOG_DEBUG ("allocated %d bytes at 0x%08lx" , (int )bytes , (long )addr );
118118 p -> data_count =
119119 + riscv_debug_buffer_size (p -> target )
120120 - (addr - riscv_debug_buffer_addr (p -> target )) / sizeof (p -> debug_buffer [0 ]);
@@ -474,17 +474,14 @@ int riscv_program_lal(struct riscv_program *p, enum gdb_regno d, riscv_addr_t ad
474474
475475int riscv_program_insert (struct riscv_program * p , riscv_insn_t i )
476476{
477- LOG_DEBUG ("instruction_count: %d (p=%p)" , (int )p -> instruction_count , p );
478-
479477 if (p -> instruction_count + p -> data_count + 1 > riscv_debug_buffer_size (p -> target )) {
480- LOG_DEBUG ("Unable to insert instruction:" );
481- LOG_DEBUG (" instruction_count=%d" , (int )p -> instruction_count );
482- LOG_DEBUG (" data_count =%d" , (int )p -> data_count );
483- LOG_DEBUG (" buffer size =%d" , (int )riscv_debug_buffer_size (p -> target ));
478+ LOG_ERROR ("Unable to insert instruction:" );
479+ LOG_ERROR (" instruction_count=%d" , (int )p -> instruction_count );
480+ LOG_ERROR (" data_count =%d" , (int )p -> data_count );
481+ LOG_ERROR (" buffer size =%d" , (int )riscv_debug_buffer_size (p -> target ));
484482 return ERROR_FAIL ;
485483 }
486484
487- LOG_DEBUG ("PROGBUF[%d] = DASM(0x%08x) [0x%08x]" , (int )p -> instruction_count , i , i );
488485 p -> debug_buffer [p -> instruction_count ] = i ;
489486 p -> instruction_count ++ ;
490487 return ERROR_OK ;
0 commit comments