***************************************************************************/
+#ifndef GDBMI_H
+#define GDBMI_H
+
#ifdef __cplusplus
-extern "C" {
+extern "C"
+{
+#if 0 /* keep Emacsens' auto-indent happy */
+}
+#endif
#endif
#include <stdio.h>
/* List children. It ONLY returns the first level information. :-( */
int gmi_var_list_children(mi_h *h, mi_gvar *var);
-#ifdef __cplusplus
-};
-/* C++ interface */
-/*
- State Can:
- disconnected Connect
- connected SelectTarget, Disconnect
- target_specified TargetUnselect, Run, Set breakpoints/watchpoints, etc.
- running Stop
- stopped Kill, Restart?, Step, Trace, Continue, etc.
- [auto exit]
-
- Modes:
- dmX11 Local debug for X11.
- dmLinux Local debug for Linux console.
- dmRemote Remote debug.
-*/
-class MIDebugger
-{
-public:
- MIDebugger();
- ~MIDebugger();
-
- enum eState { disconnected, connected, target_specified, running, stopped };
- enum dMode { dmX11, dmLinux, dmRemote, dmPID };
- enum endianType { enUnknown, enLittle, enBig };
- // Currently tested architectures
- enum archType { arUnknown, arIA32, arSPARC, arPIC14, arAVR, arUnsupported };
-
- int Connect(bool remote=false); /* remote is currently ignored. */
- int Disconnect();
- /* SelectTarget* */
- int SelectTargetX11(const char *exec, const char *args=NULL,
- const char *auxtty=NULL);
- int SelectTargetLinux(const char *exec, const char *args,
- const char *auxtty=NULL);
- int SelectTargetRemote(const char *exec, const char *rparams,
- const char *rtype=NULL, bool download=false);
- // TODO: Linux PIDs can be represented as intergers. What should I use?
- // ato_pid_t doesn't exist ;-)
- mi_frames *SelectTargetPID(const char *exec, int pid);
- int TargetUnselect();
- int Run();
- int Stop();
- int Poll(mi_stop *&rs);
- int Continue();
- int RunOrContinue();
- int Kill();
- mi_bkpt *Breakpoint(const char *file, int line);
- mi_bkpt *Breakpoint(const char *where, bool temporary=false, const char *cond=NULL,
- int count=-1, int thread=-1, bool hard_assist=false);
- mi_bkpt *BreakpointFull(const char *file, int line, bool temporary=false,
- const char *cond=NULL, int count=-1, int thread=-1,
- bool hard_assist=false);
- mi_bkpt *Breakpoint(mi_bkpt *b);
- int BreakDelete(mi_bkpt *b);
- int BreakAfter(mi_bkpt *b)
- {
- if (state!=target_specified && state!=stopped)
- return 0;
- return gmi_break_set_times(h,b->number,b->ignore);
- }
- mi_wp *Watchpoint(enum mi_wp_mode mode, const char *exp);
- int WatchDelete(mi_wp *w);
- int RunToMain();
- int StepOver(bool inst=false);
- int TraceInto(bool inst=false);
- int GoTo(const char *file, int line);
- int GoTo(void *addr);
- int FinishFun();
- mi_frames *ReturnNow();
- mi_frames *CallStack(bool args);
- char *EvalExpression(const char *exp);
- char *ModifyExpression(char *exp, char *newVal);
- mi_gvar *AddgVar(const char *exp, int frame=-1)
- {
- if (state!=stopped)
- return NULL;
- return gmi_full_var_create(h,frame,exp);
- }
- int DelgVar(mi_gvar *var)
- {
- if (state!=stopped)
- return 0;
- return gmi_var_delete(h,var);
- }
- int EvalgVar(mi_gvar *var)
- {
- if (state!=stopped)
- return 0;
- return gmi_var_evaluate_expression(h,var);
- }
- int GetChildgVar(mi_gvar *var)
- {
- if (state!=stopped)
- return 0;
- return gmi_var_list_children(h,var);
- }
- int FillTypeVal(mi_gvar *var);
- int FillOneTypeVal(mi_gvar *var);
- int FillAttr(mi_gvar *var)
- {
- if (state!=stopped)
- return 0;
- return gmi_var_show_attributes(h,var);
- }
- int FillFormat(mi_gvar *var)
- {
- if (state!=stopped)
- return 0;
- return gmi_var_show_format(h,var);
- }
- int SetFormatgVar(mi_gvar *var, enum mi_gvar_fmt format)
- {
- if (state!=stopped)
- return 0;
- return gmi_var_set_format(h,var,format);
- }
- int ListChangedgVar(mi_gvar_chg *&changed)
- {
- if (state!=stopped)
- return 0;
- return gmi_var_update(h,NULL,&changed);
- }
- int AssigngVar(mi_gvar *var, const char *exp);
- int Send(const char *command);
- int Version()
- {
- if (state==running || state==disconnected)
- return 0;
- return gmi_gdb_version(h);
- }
- int PathSources(const char *path)
- {
- if (state==running || state==disconnected)
- return 0;
- return gmi_dir(h,path);
- }
- int ReadMemory(const char *exp, unsigned size, unsigned char *dest,
- int &na, int convAddr, unsigned long *addr)
- {
- if (state!=stopped)
- return 0;
- return gmi_read_memory(h,exp,size,dest,&na,convAddr,addr);
- }
- char *Show(const char *var);
- int ThreadListIDs(int *&list)
- {
- if (state!=stopped)
- return 0;
- return gmi_thread_list_ids(h,&list);
- }
- mi_frames *ThreadList()
- {
- if (state!=stopped)
- return 0;
- return gmi_thread_list_all_threads(h);
- }
- mi_frames *ThreadSelect(int id)
- {
- if (state!=stopped)
- return NULL;
- return gmi_thread_select(h,id);
- }
- mi_asm_insns *Disassemble(const char *start, const char *end, int mode)
- {
- if (state!=stopped)
- return NULL;
- return gmi_data_disassemble_se(h,start,end,mode);
- }
- mi_asm_insns *Disassemble(const char *file, int line, int lines, int mode)
- {
- if (state!=stopped)
- return NULL;
- return gmi_data_disassemble_fl(h,file,line,lines,mode);
- }
- mi_chg_reg *GetRegisterNames(int *how_many)
- {
- if (state!=target_specified && state!=stopped)
- return NULL;
- return gmi_data_list_register_names(h,how_many);
- }
- int GetRegisterNames(mi_chg_reg *chg)
- {
- if (state!=target_specified && state!=stopped)
- return 0;
- return gmi_data_list_register_names_l(h,chg);
- }
- int GetRegisterValues(mi_chg_reg *chg)
- {
- if (state!=stopped)
- return 0;
- return gmi_data_list_register_values(h,fm_natural,chg);
- }
- mi_chg_reg *GetRegisterValues(int *how_many)
- {
- if (state!=stopped)
- return 0;
- return gmi_data_list_all_register_values(h,fm_natural,how_many);
- }
- mi_chg_reg *GetChangedRegisters()
- {
- if (state!=stopped)
- return NULL;
- mi_chg_reg *chg=gmi_data_list_changed_registers(h);
- if (chg && !gmi_data_list_register_values(h,fm_natural,chg))
- {
- mi_free_chg_reg(chg);
- chg=NULL;
- }
- return chg;
- }
- int UpdateRegisters(mi_chg_reg *regs);
-
- endianType GetTargetEndian();
- archType GetTargetArchitecture();
- eState GetState() { return state; }
-
- /* Some wrappers */
- static void SetGDBExe(const char *name) { mi_set_gdb_exe(name); }
- static const char *GetGDBExe() { return mi_get_gdb_exe(); }
- static void SetXTermExe(const char *name) { mi_set_xterm_exe(name); }
- static const char *GetXTermExe() { return mi_get_xterm_exe(); }
- static void SetGDBStartFile(const char *name) { mi_set_gdb_start(name); }
- static const char *GetGDBStartFile() { return mi_get_gdb_start(); }
- static void SetGDBConnFile(const char *name) { mi_set_gdb_conn(name); }
- static const char *GetGDBConnFile() { return mi_get_gdb_conn(); }
- static void SetMainFunc(const char *name) { mi_set_main_func(name); }
- static const char *GetMainFunc() { return mi_get_main_func(); }
-
- static const char *GetErrorStr() { return mi_get_error_str(); }
- static const char *GetGDBError() { return mi_error_from_gdb; }
- static int GetErrorNumber() { return mi_error; }
- int GetErrorNumberSt();
- void SetConsoleCB(stream_cb cb, void *data=NULL)
- { mi_set_console_cb(h,cb,data); }
- void SetTargetCB(stream_cb cb, void *data=NULL)
- { mi_set_target_cb(h,cb,data); }
- void SetLogCB(stream_cb cb, void *data=NULL)
- { mi_set_log_cb(h,cb,data); }
- void SetAsyncCB(async_cb cb, void *data=NULL)
- { mi_set_async_cb(h,cb,data); }
- void SetToGDBCB(stream_cb cb, void *data=NULL)
- { mi_set_to_gdb_cb(h,cb,data); }
- void SetFromGDBCB(stream_cb cb, void *data=NULL)
- { mi_set_from_gdb_cb(h,cb,data); }
- void SetTimeOutCB(tm_cb cb, void *data)
- { mi_set_time_out_cb(h,cb,data); }
- void SetTimeOut(int to)
- { mi_set_time_out(h,to); }
- void ForceMIVersion(unsigned vMajor, unsigned vMiddle, unsigned vMinor)
- { mi_force_version(h,vMajor,vMiddle,vMinor); }
-
- const char *GetAuxTTY()
- { return aux_tty ? aux_tty->tty : NULL; }
-
-protected:
- eState state;
- dMode mode;
- endianType targetEndian;
- archType targetArch;
- bool preRun; // Remote targets starts running but outside main.
- mi_h *h;
- mi_aux_term *aux_tty;
- int waitingTempBkpt;
-
- int SelectTargetTTY(const char *exec, const char *args, const char *auxtty,
- dMode m);
-};
+#if 0 /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
#endif
+#endif