Пример #1
0
func (wks *workspace) removeBreakpoint(cmd *breakpoint_cmd, gdb *gdbmi.GDB) error {
	bp := new(breakpoint_data)
	if err := json.Unmarshal(cmd.Data, bp); err != nil {
		return err
	}
	fs := wks.filesystems[bp.Filesystem]
	abspath := fs.Abs(bp.Source)

	if gdb.Running {
		_, err := gdb.Exec_interrupt(false, nil)
		if err != nil {
			return err
		}
		defer gdb.Exec_continue(true, false, nil)
	}

	bplist, err := gdb.Break_list()
	if err != nil {
		return err
	}
	for _, bpt := range *bplist {
		if bpt.Fullname == abspath && bpt.Line == bp.Line {
			if _, err := gdb.Break_delete(bpt.Number); err != nil {
				return err
			}
			return nil
		}
	}
	return fmt.Errorf("breakpoint %s:%d not found", abspath, bp.Line)
}
Пример #2
0
func (wks *workspace) addBreakpoint(cmd *breakpoint_cmd, gdb *gdbmi.GDB) error {
	bp := new(breakpoint_data)
	if err := json.Unmarshal(cmd.Data, bp); err != nil {
		return err
	}
	fs := wks.filesystems[bp.Filesystem]
	abspath := fs.Abs(bp.Source)

	if gdb.Running {
		_, err := gdb.Exec_interrupt(false, nil)
		if err != nil {
			return err
		}
		defer gdb.Exec_continue(true, false, nil)
	}

	bpkt, err := gdb.Breakpoint(abspath, bp.Line)
	if err != nil {
		return nil
	}
	debuglogger.Infof("new breakpoint set: %+v", bpkt)
	return nil
}