Using IDA Pro's tracing features. © DataRescue 2005The first debugger tutorial explained how to use traditional debugger commands in order to debug a simple buggy C console program. This small tutorial will present another approach to debug t his a pplication, by i ntroducing t he t racing func tionalities of ID A 's de bugger.The buggy program.This progra m s imply c omputes a verages of a s et of va lues (1, 2, 3, 4 a nd 5). T hose va lues a re s tored in t wo a rrays: one c ontaining 8 bi t va lues, the ot her c ontaining 32-bi t va lues. #include char char_average( char array[], int count){ int i; char average; average = 0; for (i = 0; i < count; i++) average += array[i]; average /= count; return average;}int int_average( int array[], int count){ int i, average; average = 0; for (i = 0; i < count; i++) average += array[i]; average /= count; return average;}void main( void) { char chars[] = { 1, 2, 3, 4, 5 }; int integers[] = { 1, 2, 3, 4, 5 }; printf( "chars[] - average = %d\n ", char_average(chars, sizeof(chars))); printf( "integers[] - average = %d\n ", int_average(integers, sizeof(integers)));}IDA Pro Tracing Tutorial 1Running t his progra m gi ves us t he fol lowing re sults: chars[] - average = 3integers[] - average = 1054228Obviously, t he c omputed a verage on t he i nteger a rray i s w rong. L et's us e ID A 's de bugger t o understand t he ori gin of t his e rror ! ...
Voir