Skip to content

Commit

Permalink
debugger: add cfgt support
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed Dec 15, 2015
1 parent 9ee0bd9 commit 1b57665
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/debugger/debugger_api.c
Expand Up @@ -26,6 +26,7 @@
#include <stdlib.h>
#include <unistd.h>

#include "../cfgt/cfgt.h"
#include "../../dprint.h"
#include "../../events.h"
#include "../../locking.h"
Expand Down Expand Up @@ -70,6 +71,7 @@ str *dbg_get_state_name(int t)
#define DBG_CFGTRACE_ON (1<<0)
#define DBG_ABKPOINT_ON (1<<1)
#define DBG_LBKPOINT_ON (1<<2)
#define DBG_CFGTEST_ON (1<<3)

static str _dbg_status_list[] = {
str_init("cfgtrace-on"),
Expand All @@ -78,6 +80,8 @@ static str _dbg_status_list[] = {
str_init("abkpoint-off"),
str_init("lbkpoint-on"),
str_init("lbkpoint-off"),
str_init("cfgtest-on"),
str_init("cfgtest-off"),
{0, 0}
};

Expand All @@ -89,6 +93,8 @@ str *dbg_get_status_name(int t)
return &_dbg_status_list[2];
if(t&DBG_LBKPOINT_ON)
return &_dbg_status_list[4];
if(t&DBG_CFGTEST_ON)
return &_dbg_status_list[6];

return &_dbg_state_list[0];
}
Expand Down Expand Up @@ -188,6 +194,12 @@ int _dbg_step_loops = 200;
*/
int _dbg_reset_msgid = 0;

/**
* disabled by default
*/
int _dbg_cfgtest = 0;
cfgt_api_t _dbg_cfgt;

/**
*
*/
Expand Down Expand Up @@ -356,6 +368,11 @@ int dbg_cfg_trace(void *data)
);
}
}
if(_dbg_pid_list[process_no].set&DBG_CFGTEST_ON)
{
if(_dbg_cfgt.cfgt_process_route(msg, a)<0)
LM_ERR("Error processing route\n");
}
if(!(_dbg_pid_list[process_no].set&DBG_ABKPOINT_ON))
{
/* no breakpoints to be considered */
Expand Down Expand Up @@ -590,6 +607,8 @@ int dbg_init_mypid(void)
_dbg_pid_list[process_no].set |= DBG_ABKPOINT_ON;
if(_dbg_cfgtrace==1)
_dbg_pid_list[process_no].set |= DBG_CFGTRACE_ON;
if(_dbg_cfgtest==1)
_dbg_pid_list[process_no].set |= DBG_CFGTEST_ON;
if(_dbg_reset_msgid==1)
{
LM_DBG("[%d] create locks\n", process_no);
Expand Down
21 changes: 21 additions & 0 deletions modules/debugger/debugger_mod.c
Expand Up @@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>

#include "../cfgt/cfgt.h"
#include "../../sr_module.h"
#include "../../dprint.h"
#include "../../ut.h"
Expand Down Expand Up @@ -71,6 +72,10 @@ extern char *_dbg_cfgtrace_lname;
extern int _dbg_step_usleep;
extern int _dbg_step_loops;
extern int _dbg_reset_msgid;
extern int _dbg_cfgtest;

/* cfgt api */
extern cfgt_api_t _dbg_cfgt;

static int _dbg_sip_msg_cline;
static char * _dbg_cfgtrace_facility_str = 0;
Expand Down Expand Up @@ -111,6 +116,7 @@ static param_export_t params[]={
{"mod_facility", PARAM_STRING|USE_FUNC_PARAM, (void*)dbg_mod_facility_param},
{"reset_msgid", INT_PARAM, &_dbg_reset_msgid},
{"cfgpkgcheck", INT_PARAM, &_dbg_cfgpkgcheck},
{"cfgtest", INT_PARAM, &_dbg_cfgtest},
{0, 0, 0}
};

Expand All @@ -136,6 +142,8 @@ struct module_exports exports = {
static int mod_init(void)
{
int fl;
bind_cfgt_t bind_cfgt;

if (_dbg_cfgtrace_facility_str!=NULL)
{
fl = str2facility(_dbg_cfgtrace_facility_str);
Expand Down Expand Up @@ -187,6 +195,19 @@ static int mod_init(void)
return -1;
}
}
if(_dbg_cfgtest==1)
{
bind_cfgt = (bind_cfgt_t)find_export("cfgt_bind_cfgt", 1, 0);
if (!bind_cfgt) {
LM_ERR("can't find cfgt module\n");
return -1;
}

if (bind_cfgt(&_dbg_cfgt) < 0) {
return -1;
}
LM_INFO("bind to cfgt module\n");
}
return dbg_init_bp_list();
}

Expand Down
22 changes: 22 additions & 0 deletions modules/debugger/doc/debugger_admin.xml
Expand Up @@ -418,6 +418,28 @@ modparam("debugger", "reset_msgid", 1)
</example>
</section>

<section id="dbg.p.cfgtest">
<title><varname>cfgtest</varname> (int)</title>
<para>
Control whether the cfgt module is enabled or disabled
at startup. Module cfgt needs to be loaded before.
</para>
<para>
<emphasis>
Default value is <quote>0</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>cfgtest</varname> parameter</title>
<programlisting format="linespecific">
...
loadmodule "cfgt.so"
modparam("debugger", "cfgtest", 1)
...
</programlisting>
</example>
</section>

</section>

<section>
Expand Down

0 comments on commit 1b57665

Please sign in to comment.