Exemplo n.º 1
0
func fetchCurrentDebugState(gdb *gdbmi.GDB, fs map[string]filesystem.WorkspaceFS) debugger_state {
	var state debugger_state
	frames, err := gdb.Stack_list_allframes()
	if err == nil {
		sf := patchFrameSourceLocations(frames, fs)
		state.Frames = *sf
	}
	vars, err := gdb.Stack_list_variables(gdbmi.ListType_all_values)
	if err == nil {
		state.Variables = *vars
	}
	return state
}
Exemplo n.º 2
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)
}
Exemplo n.º 3
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
}