@@ -9739,9 +9739,48 @@ static void cmd_anal_opcode_bits(RCore *core, const char *arg, int mode) {
97399739 }
97409740}
97419741
9742+ static void cmd_aoc (RCore * core , const char * input ) {
9743+ RListIter * iter ;
9744+ RAnalCycleHook * hook ;
9745+ char ch = input [1 ];
9746+ if (ch == '?' ) {
9747+ r_core_cmd_help_contains (core , help_msg_ao , "aoc" );
9748+ return ;
9749+ }
9750+ if (ch && ch != ' ' ) {
9751+ r_core_return_invalid_command (core , "aoc" , ch );
9752+ return ;
9753+ }
9754+ const int ccl = input [1 ]? r_num_math (core -> num , input + 2 ): 0 ;
9755+ if (ccl < 0 ) {
9756+ R_LOG_ERROR ("aoc expects a positive number" );
9757+ return ;
9758+ }
9759+ RConfigHold * hc = r_config_hold_new (core -> config );
9760+ r_config_hold (hc , "asm.cmt.right" , "asm.functions" , "asm.lines" , "asm.xrefs" , NULL );
9761+ r_config_set_b (core -> config , "asm.cmt.right" , true);
9762+ r_config_set_b (core -> config , "asm.functions" , false);
9763+ r_config_set_b (core -> config , "asm.lines" , false);
9764+ r_config_set_b (core -> config , "asm.xrefs" , false);
9765+
9766+ RList * hooks = r_core_anal_cycles (core , ccl );
9767+ r_list_foreach (hooks , iter , hook ) {
9768+ char * ins = r_core_disassemble_instr (core , hook -> addr , 1 );
9769+ if (ins ) {
9770+ size_t count = ccl - hook -> cycles ;
9771+ r_cons_printf (core -> cons , "after %i cycles: %s\n" , count , ins );
9772+ free (ins );
9773+ }
9774+ }
9775+ r_list_free (hooks );
9776+
9777+ r_config_hold_restore (hc );
9778+ r_config_hold_free (hc );
9779+ }
9780+
97429781static void cmd_anal_opcode (RCore * core , const char * input ) {
9743- int l , len = core -> blocksize ;
97449782 ut32 tbs = core -> blocksize ;
9783+ int l , len = tbs ;
97459784 r_core_block_read (core );
97469785 switch (input [0 ]) {
97479786 case 's' : // "aos"
@@ -9857,39 +9896,8 @@ static void cmd_anal_opcode(RCore *core, const char *input) {
98579896 }
98589897 break ;
98599898 case 'c' : // "aoc"
9860- {
9861- RList * hooks ;
9862- RListIter * iter ;
9863- RAnalCycleHook * hook ;
9864- char * instr_tmp = NULL ;
9865- int ccl = input [1 ]? r_num_math (core -> num , & input [2 ]): 0 ; //get cycles to look for
9866- bool cr = r_config_get_b (core -> config , "asm.cmt.right" );
9867- bool fu = r_config_get_b (core -> config , "asm.functions" );
9868- bool li = r_config_get_b (core -> config , "asm.lines" );
9869- bool xr = r_config_get_b (core -> config , "asm.xrefs" );
9870-
9871- r_config_set_b (core -> config , "asm.cmt.right" , true);
9872- r_config_set_b (core -> config , "asm.functions" , false);
9873- r_config_set_b (core -> config , "asm.lines" , false);
9874- r_config_set_b (core -> config , "asm.xrefs" , false);
9875-
9876- hooks = r_core_anal_cycles (core , ccl ); // analyse
9877- r_list_foreach (hooks , iter , hook ) {
9878- instr_tmp = r_core_disassemble_instr (core , hook -> addr , 1 );
9879- if (instr_tmp ) {
9880- r_cons_printf (core -> cons , "After %4i cycles:\t%s" , (ccl - hook -> cycles ), instr_tmp );
9881- r_cons_flush (core -> cons );
9882- free (instr_tmp );
9883- }
9884- }
9885- r_list_free (hooks );
9886-
9887- r_config_set_b (core -> config , "asm.cmt.right" , cr ); //reset settings
9888- r_config_set_b (core -> config , "asm.functions" , fu );
9889- r_config_set_b (core -> config , "asm.lines" , li );
9890- r_config_set_b (core -> config , "asm.xrefs" , xr );
9891- }
9892- break ;
9899+ cmd_aoc (core , input );
9900+ break ;
98939901 case 'd' : // "aod"
98949902 if (input [1 ] == 'a' ) { // "aoda"
98959903 // list sdb database
0 commit comments