Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tcf-dev] Check no_read before reading register

Hi,

This is a minor, but in agent/tcf/services/stacktrace.c:trace_stack(), shouldn’t RegisterDefinition.no_read

be checked before reading with read_reg_value(), line 222 below?

 

    216 #if ENABLE_Trace

    217         if (LOG_STACK & log_mode) {

    218             uint64_t v;

    219             RegisterDefinition * def;

    220             trace(LOG_STACK, "Frame %d", stack->frame_cnt - 1);

    221             for (def = get_reg_definitions(ctx); def->name != NULL; def++) {

    222                 if (read_reg_value(frame, def, &v) == 0) {

    223                     trace(LOG_STACK, "  %-8s %16"PRIX64, def->name, v);

    224                 }

    225             }

    226         }

    227 #endif

 

Line 222 could be: if (def->no_read == 0 && read_reg_value(frame, def, &v) == 0) {

 

Or if logging of failure to read a readable register could be logged:

if (def->no_read == 0) {

if (read_reg_value(frame, def, &v) == 0) {

                    trace(LOG_STACK, "  %-8s %16"PRIX64, def->name, v);

} else {

trace(LOG_STACK, "Failed to read register:%s", def->name);

}

}

 

What do you think about this change?

 

Best regards,

Claes

 

----------------------------------------------------------------------
Intel Sweden AB
Registered Office: Isafjordsgatan 30B, 164 40 Kista, Stockholm, Sweden
Registration Number: 556189-6027

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


Back to the top