From 69e35391a5a648b6d2b9a59f38a81b5ce871174d Mon Sep 17 00:00:00 2001 From: "elias.bachaalany" Date: Wed, 5 May 2010 13:11:36 +0000 Subject: [PATCH] idd.i: added dbg_get_name() to get the current debugger's name --- swig/dbg.i | 20 ++++++++++---------- swig/idd.i | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/swig/dbg.i b/swig/dbg.i index 9c96d7d..3824f73 100644 --- a/swig/dbg.i +++ b/swig/dbg.i @@ -15,7 +15,7 @@ typedef struct %{ // -PyObject *meminfo_vec_t_to_py(meminfo_vec_t &areas); +static PyObject *meminfo_vec_t_to_py(meminfo_vec_t &areas); // %} @@ -23,7 +23,7 @@ PyObject *meminfo_vec_t_to_py(meminfo_vec_t &areas); // //------------------------------------------------------------------------- -PyObject *py_get_manual_regions() +static PyObject *py_get_manual_regions() { meminfo_vec_t areas; get_manual_regions(&areas); @@ -31,7 +31,7 @@ PyObject *py_get_manual_regions() } //------------------------------------------------------------------------- -PyObject *refresh_debugger_memory() +static PyObject *refresh_debugger_memory() { invalidate_dbgmem_config(); invalidate_dbgmem_contents(BADADDR, BADADDR); @@ -42,7 +42,7 @@ PyObject *refresh_debugger_memory() // int idaapi DBG_Callback(void *ud, int notification_code, va_list va); -class DBG_Hooks +class DBG_Hooks { public: virtual ~DBG_Hooks() {}; @@ -72,8 +72,8 @@ public: virtual void dbg_thread_start(pid_t pid, thid_t tid, ea_t ea) { }; - virtual void dbg_thread_exit(pid_t pid, - thid_t tid, + virtual void dbg_thread_exit(pid_t pid, + thid_t tid, ea_t ea, int exit_code) { }; virtual void dbg_library_load(pid_t pid, @@ -100,7 +100,7 @@ public: virtual void dbg_suspend_process(void) { }; virtual int dbg_bpt(thid_t tid, ea_t breakpoint_ea) { return 0; }; virtual int dbg_trace(thid_t tid, ea_t ip) { return 0; }; - virtual void dbg_request_error(ui_notification_t failed_command, + virtual void dbg_request_error(ui_notification_t failed_command, dbg_notification_t failed_dbg_notification) { }; virtual void dbg_step_into(void) { }; virtual void dbg_step_over(void) { }; @@ -250,9 +250,9 @@ int idaapi DBG_Callback(void *ud, int notification_code, va_list va) return 0; } } - catch (Swig::DirectorException &) - { - msg("Exception in IDP Hook function:\n"); + catch (Swig::DirectorException &) + { + msg("Exception in IDP Hook function:\n"); if (PyErr_Occurred()) { PyErr_Print(); diff --git a/swig/idd.i b/swig/idd.i index 435641c..52a62d6 100644 --- a/swig/idd.i +++ b/swig/idd.i @@ -12,7 +12,7 @@ // //------------------------------------------------------------------------- -bool dbg_can_query() +static bool dbg_can_query() { // Reject the request only if no debugger is set // or the debugger cannot be queried while not in suspended state @@ -20,12 +20,12 @@ bool dbg_can_query() } //------------------------------------------------------------------------- -PyObject *meminfo_vec_t_to_py(meminfo_vec_t &areas) +static PyObject *meminfo_vec_t_to_py(meminfo_vec_t &areas) { PyObject *py_list = PyList_New(areas.size()); meminfo_vec_t::const_iterator it, it_end(areas.end()); Py_ssize_t i = 0; - for (it=areas.begin();it!=it_end;++it, ++i) + for ( it=areas.begin(); it!=it_end; ++it, ++i ) { const memory_info_t &mi = *it; // startEA endEA name sclass sbase bitness perm @@ -162,7 +162,7 @@ PyObject *py_appcall( PyObject *py_fields, PyObject *arg_list) { - if (!PyList_Check(arg_list)) + if ( !PyList_Check(arg_list) ) return NULL; const char *type = py_type == Py_None ? NULL : PyString_AS_STRING(py_type); @@ -174,7 +174,7 @@ PyObject *py_appcall( Py_ssize_t nargs = PyList_Size(arg_list); idc_args.resize(nargs); bool ok = true; - for (Py_ssize_t i=0;i%s\n", int(i), s.c_str()); } // Convert it - if (pyvar_to_idcvar(py_item, &idc_args[i], &sn) < CIP_OK) + if ( pyvar_to_idcvar(py_item, &idc_args[i], &sn) < CIP_OK ) { ok = false; break; @@ -193,7 +193,7 @@ PyObject *py_appcall( } // Set exception message - if (!ok) + if ( !ok ) { PyErr_SetString(PyExc_ValueError, "PyAppCall: Failed to convert Python values to IDC values"); return NULL; @@ -300,7 +300,14 @@ PyObject *dbg_read_memory(PyObject *py_ea, PyObject *py_sz); PyObject *dbg_get_thread_sreg_base(PyObject *py_tid, PyObject *py_sreg_value); PyObject *dbg_get_registers(); PyObject *dbg_get_memory_info(); -bool dbg_can_query(); +static PyObject *dbg_get_name() +{ + if ( dbg == NULL ) + Py_RETURN_NONE; + return PyString_FromString(dbg->name); +} + +static bool dbg_can_query(); PyObject *py_appcall( ea_t func_ea, thid_t tid,