def mdown_func(self, args, from_tty): steps = 1 s = str(args).split() if len(s) is 1: try: steps = int(s[0]) except: pass elif len(s) > 1: self.usage() return selected_frame = m_frame.get_selected_frame() newest_frame = m_frame.get_newest_frame() if not selected_frame or not newest_frame: gdb_print('Unable to locate Maple frame') return # walk through from innermost frame to selected frame # to get the level number from newest frame to selected frame. index = 0 frame = newest_frame while frame != selected_frame and frame: frame = m_frame.get_next_older_frame(frame) index += 1 if not frame: gdb_print('No valid frames found') return prev_maple_frame = frame prev_maple_frame_index = index while frame and steps > 0: frame = m_frame.get_next_newer_frame(frame) if frame: m_util.gdb_exec_to_null('down-silently') index -= 1 else: frame = prev_maple_frame m_util.gdb_exec_to_null('up-silently ' + str(index - prev_maple_frame_index)) index = prev_maple_frame_index break if m_frame.is_maple_frame(frame): prev_maple_frame = frame prev_maple_frame_index = index steps -= 1 print_maple_frame(frame, index, MBT_FORMAT_SRC) m_datastore.mgdb_rdata.update_frame_change_counter()
def mbt_func(self, args, from_tty): s = str(args) mbt_format = MBT_FORMAT_SRC full = False if s == "-full" or s == "full": full = True elif s == "-asm": mbt_format = MBT_FORMAT_ASM elif s == "-mir": mbt_format = MBT_FORMAT_MIR selected_frame = m_frame.get_selected_frame() newest_frame = m_frame.get_newest_frame() if not selected_frame or not newest_frame: gdb_print('Unable to locate Maple frame') return # walk through from innermost frame to selected frame index = 0 frame = newest_frame while frame != selected_frame and frame: frame = m_frame.get_next_older_frame(frame) index += 1 if not frame: gdb_print('No valid frames found') return start_level = index gdb_print('Maple Traceback (most recent call first):') while frame: if m_frame.is_maple_frame(frame): print_maple_frame(frame, index, mbt_format) elif full: print_gdb_frame(frame, index) index += 1 frame = m_frame.get_next_older_frame(frame) if frame: m_util.gdb_exec_to_null('up-silently') # move frame back to the original stack level m_util.gdb_exec_to_null('down-silently ' + str(index - start_level - 1))
def mstepi_common_dync(self, threadno, count): msi_bp_dync_exist, msi_bp_dync_id = is_msi_bp_dync_existed() if not msi_bp_dync_exist: # there is no msi bp exist, so just create a new msi breakpoint self.init_gdb_breakpoint(threadno, count, False, True) else: if msi_bp_dync_id != self.msi_bp_dync_id: # if existing msi bp id does not match to self.msi_bp_id gdb_print( "There are one or more breakpints already created at __inc_opcode_cnt_dyn\n" "In order to use mstepi command, please delete those breakpoints first\n" ) return None else: # the existing msi bp id matches to self.msi_bp_id, it was created # by mstepi command previously. if self.msi_bp_dync_id.enabled is False: enable_msi_bp_dync() self.mbp_dync_object.set_bp_attr('thread', threadno) self.mbp_dync_object.set_bp_attr('count', count) assert count > 0 if self.mbp_dync_object.ignore_count != count - 1: self.mbp_dync_object.ignore_count = count - 1 hitcnt = self.mbp_dync_object.hit_count # It is important to perform a continue command here for the msi breakpoint # to be reached. m_util.gdb_exec("continue") """ if the msi breakpoint's count reaches to 1, it will return True to cause gdb stop at msi breakpoint by previous 'continue' command. Once gdb stops here, a gdb 'finish' command shall be called. However, 'finish' command must NOT be called inside of msi breakpoint stop() logic """ frame = None if self.mbp_dync_object.hit_count - hitcnt == count: """ if gdb stops here, it must have hit one breakpoint. However. the breakpoint it hits may not be the msi breakpoint, it could be another breakpoint the user set up. In this case, we check if it is a Maple frame. If it is, then the breakpoint is ours. Otherwise just stop here and return because it hit a user's other stop. """ frame = m_frame.get_selected_frame() if not frame: return None if not m_frame.is_maple_frame(frame): if m_set.msettings['opcode'] == 'on': m_util.gdb_exec("finish") else: silent_finish() # now get the new selected frame frame = m_frame.get_selected_frame() if not frame: return None # this will update the Maple gdb runtime metadata store. m_datastore.mgdb_rdata.update_gdb_runtime_data() m_datastore.mgdb_rdata.update_frame_change_counter() # always disable msi breakpoint after msi is excuted disable_msi_bp_dync() return frame