Compaq AA-RH99A-TE Remote Starter User Manual


 
Example 3–2: Extension That Uses Linked Lists: callout.c (cont.)
sprintf(buf, "set $hexints=0");
dbx(buf, False);
sprintf(buf, "p \*(long \*)0x%lx", headptr+8*i);
dbx(buf, True);
if((resp = read_response(&status)) == NULL){
print_status("Couldnt read value of processor_ptr[i]:", &status);
quit(1);
}
ptr_val = strtoul(resp, (char**)NULL, 10);
free(resp);
if (! ptr_val) continue; /* continue if this slot is disabled */
if(!cast(ptr_val, "struct processor", &processor, &error)){
fprintf(stderr, "Couldnt cast to a processor:\n");
fprintf(stderr, "%s:\n", error);
quit(1);
}
if(!read_field_vals(processor, processor_fields, NUM_PROCESSOR_FIELDS)){
field_errors(processor_fields, NUM_PROCESSOR_FIELDS);
quit(1);
}
if (processor_fields[5].data == 0) continue;
print("");
sprintf(buf, "Processor: %10u", i);
print(buf);
sprintf(buf, "Current time (in ticks): %10u",
processor_fields[4].data ); /*lbolt*/
print(buf);
/* for first element, we are interested in time only */
print("");
sprintf(buf, " FUNCTION ARGUMENT TICKS(delta)");
print(buf);
print( "============================= ============ ============");
/* walk through the rest of the list */
next = (long) processor_fields[3].data;
while(next != 0) {
if(!cast(next, "struct callout", &callout, &error)){
fprintf(stderr, "Couldnt cast to a callout:\n");
fprintf(stderr, "%s:\n", error);
}
if(!read_field_vals(callout, callout_fields, NUM_CALLOUT_FIELDS)){
field_errors(callout_fields, NUM_CALLOUT_FIELDS);
break;
}
func = addr_to_proc((long) callout_fields[2].data);
format_addr((long) callout_fields[1].data, arg);
sprintf(buf, "%-32.32s %12s %12d", func, arg,
((long)callout_fields[0].data & CALLTODO_TIME) -
(long)processor_fields[4].data);
print(buf);
next = (long) callout_fields[3].data;
3–26 Writing Extensions to the kdbx Debugger