| 1 |
debugger Module |
| 2 |
|
| 3 |
Daniel-Constantin Mierla |
| 4 |
|
| 5 |
asipto.com |
| 6 |
|
| 7 |
Edited by |
| 8 |
|
| 9 |
Daniel-Constantin Mierla |
| 10 |
|
| 11 |
<[email protected]> |
| 12 |
|
| 13 |
Copyright © 2010 Daniel-Constantin Mierla (asipto.com) |
| 14 |
__________________________________________________________________ |
| 15 |
|
| 16 |
Table of Contents |
| 17 |
|
| 18 |
1. Admin Guide |
| 19 |
|
| 20 |
1. Overview |
| 21 |
2. Dependencies |
| 22 |
|
| 23 |
2.1. Kamailio Modules |
| 24 |
2.2. External Libraries or Applications |
| 25 |
|
| 26 |
3. Parameters |
| 27 |
|
| 28 |
3.1. cfgtrace (int) |
| 29 |
3.2. cfgtrace_format (int) |
| 30 |
3.3. breakpoint (int) |
| 31 |
3.4. log_level (int) |
| 32 |
3.5. log_level_name (str) |
| 33 |
3.6. log_facility (str) |
| 34 |
3.7. log_prefix (str) |
| 35 |
3.8. step_usleep (int) |
| 36 |
3.9. step_loops (int) |
| 37 |
3.10. mod_hash_size (int) |
| 38 |
3.11. mod_level_mode (int) |
| 39 |
3.12. mod_level (str) |
| 40 |
3.13. mod_facility_mode (int) |
| 41 |
3.14. mod_facility (str) |
| 42 |
3.15. log_assign (int) |
| 43 |
3.16. cfgpkgcheck (int) |
| 44 |
3.17. reset_msgid (int) |
| 45 |
3.18. cfgtest (int) |
| 46 |
|
| 47 |
4. Functions |
| 48 |
|
| 49 |
4.1. dbg_breakpoint(mode) |
| 50 |
4.2. dbg_pv_dump([mask] [, level]) |
| 51 |
4.3. dbg_sip_msg([log_level], [facility]) |
| 52 |
|
| 53 |
5. RPC Commands |
| 54 |
|
| 55 |
5.1. dbg.ls |
| 56 |
5.2. dbg.trace |
| 57 |
5.3. dbg.bp |
| 58 |
5.4. dbg.mod_level |
| 59 |
5.5. dbg.reset_msgid |
| 60 |
5.6. dbg.set_mod_level |
| 61 |
5.7. dbg.set_mod_facility |
| 62 |
5.8. dbg.get_mod_level |
| 63 |
5.9. dbg.get_mod_facility |
| 64 |
|
| 65 |
6. Usage |
| 66 |
|
| 67 |
List of Examples |
| 68 |
|
| 69 |
1.1. Set cfgtrace parameter |
| 70 |
1.2. Set cfgtrace_format parameter |
| 71 |
1.3. Set breakpoint parameter |
| 72 |
1.4. Set log_level parameter |
| 73 |
1.5. Set log_level_name parameter |
| 74 |
1.6. Set log_facility parameter |
| 75 |
1.7. Set log_prefix parameter |
| 76 |
1.8. Set step_usleep parameter |
| 77 |
1.9. Set step_loops parameter |
| 78 |
1.10. Set mod_hash_size parameter |
| 79 |
1.11. Set mod_level_mode parameter |
| 80 |
1.12. Set mod_level parameter |
| 81 |
1.13. Set mod_facility_mode parameter |
| 82 |
1.14. Set mod_facility parameter |
| 83 |
1.15. Set log_assign parameter |
| 84 |
1.16. Set cfgpkgcheck parameter |
| 85 |
1.17. Set reset_msgid parameter |
| 86 |
1.18. Set cfgtest parameter |
| 87 |
1.19. dbg_breakpoint usage |
| 88 |
1.20. dbg_pv_dump usage |
| 89 |
1.21. dbg_sip_msg usage |
| 90 |
|
| 91 |
Chapter 1. Admin Guide |
| 92 |
|
| 93 |
Table of Contents |
| 94 |
|
| 95 |
1. Overview |
| 96 |
2. Dependencies |
| 97 |
|
| 98 |
2.1. Kamailio Modules |
| 99 |
2.2. External Libraries or Applications |
| 100 |
|
| 101 |
3. Parameters |
| 102 |
|
| 103 |
3.1. cfgtrace (int) |
| 104 |
3.2. cfgtrace_format (int) |
| 105 |
3.3. breakpoint (int) |
| 106 |
3.4. log_level (int) |
| 107 |
3.5. log_level_name (str) |
| 108 |
3.6. log_facility (str) |
| 109 |
3.7. log_prefix (str) |
| 110 |
3.8. step_usleep (int) |
| 111 |
3.9. step_loops (int) |
| 112 |
3.10. mod_hash_size (int) |
| 113 |
3.11. mod_level_mode (int) |
| 114 |
3.12. mod_level (str) |
| 115 |
3.13. mod_facility_mode (int) |
| 116 |
3.14. mod_facility (str) |
| 117 |
3.15. log_assign (int) |
| 118 |
3.16. cfgpkgcheck (int) |
| 119 |
3.17. reset_msgid (int) |
| 120 |
3.18. cfgtest (int) |
| 121 |
|
| 122 |
4. Functions |
| 123 |
|
| 124 |
4.1. dbg_breakpoint(mode) |
| 125 |
4.2. dbg_pv_dump([mask] [, level]) |
| 126 |
4.3. dbg_sip_msg([log_level], [facility]) |
| 127 |
|
| 128 |
5. RPC Commands |
| 129 |
|
| 130 |
5.1. dbg.ls |
| 131 |
5.2. dbg.trace |
| 132 |
5.3. dbg.bp |
| 133 |
5.4. dbg.mod_level |
| 134 |
5.5. dbg.reset_msgid |
| 135 |
5.6. dbg.set_mod_level |
| 136 |
5.7. dbg.set_mod_facility |
| 137 |
5.8. dbg.get_mod_level |
| 138 |
5.9. dbg.get_mod_facility |
| 139 |
|
| 140 |
6. Usage |
| 141 |
|
| 142 |
1. Overview |
| 143 |
|
| 144 |
This module provides an interactive config file debugger. It can print |
| 145 |
a trace of config script execution for a SIP message to log and set |
| 146 |
breakpoints on every script action, allowing step-by-step execution of |
| 147 |
the routing and response scripts. Moreover, this module allows setting |
| 148 |
static and dynamic module specific debug settings. |
| 149 |
|
| 150 |
Debugging can be done from local or remote host via RPC interface |
| 151 |
(e.g., XMLRPC, kamcmd, siremis). |
| 152 |
|
| 153 |
The framework to set breakpoints on specific actions and config lines |
| 154 |
is not exported to RPC. Each action can be accompanied by a breakpoint |
| 155 |
or you can use dbg_breakpoint() function to set a breakpoint at certain |
| 156 |
line. Global breakpoints can be enabled/disabled at runtime. The script |
| 157 |
running trace can also be enabled/disabled at runtime. |
| 158 |
|
| 159 |
When the SIP router process is stopped at a breakpoint, you can |
| 160 |
investigate the values of any pseudo-variables. Note that some of |
| 161 |
pseudo-variables may produce memory leaks; a fix is planned in the |
| 162 |
future (here fall pseudo-variables with dynamic name such as htable, |
| 163 |
sqlops). References to SIP message, avps, headers, script and shared |
| 164 |
variables are safe. |
| 165 |
|
| 166 |
2. Dependencies |
| 167 |
|
| 168 |
2.1. Kamailio Modules |
| 169 |
2.2. External Libraries or Applications |
| 170 |
|
| 171 |
2.1. Kamailio Modules |
| 172 |
|
| 173 |
The following modules must be loaded before this module: |
| 174 |
* none. |
| 175 |
|
| 176 |
NOTE: Due to the debugger module child_init() function, one should load |
| 177 |
the module first in the module sequence in order to initialize |
| 178 |
_dbg_pid_list. Otherwise, another module (i.e. p_usrloc) forking a |
| 179 |
process with rank != PROC_INIT will fail. |
| 180 |
|
| 181 |
2.2. External Libraries or Applications |
| 182 |
|
| 183 |
The following libraries or applications must be installed before |
| 184 |
running Kamailio with this module loaded: |
| 185 |
* None. |
| 186 |
|
| 187 |
3. Parameters |
| 188 |
|
| 189 |
3.1. cfgtrace (int) |
| 190 |
3.2. cfgtrace_format (int) |
| 191 |
3.3. breakpoint (int) |
| 192 |
3.4. log_level (int) |
| 193 |
3.5. log_level_name (str) |
| 194 |
3.6. log_facility (str) |
| 195 |
3.7. log_prefix (str) |
| 196 |
3.8. step_usleep (int) |
| 197 |
3.9. step_loops (int) |
| 198 |
3.10. mod_hash_size (int) |
| 199 |
3.11. mod_level_mode (int) |
| 200 |
3.12. mod_level (str) |
| 201 |
3.13. mod_facility_mode (int) |
| 202 |
3.14. mod_facility (str) |
| 203 |
3.15. log_assign (int) |
| 204 |
3.16. cfgpkgcheck (int) |
| 205 |
3.17. reset_msgid (int) |
| 206 |
3.18. cfgtest (int) |
| 207 |
|
| 208 |
3.1. cfgtrace (int) |
| 209 |
|
| 210 |
Control whether the config script trace is enabled or disabled at |
| 211 |
startup. You can change the value at runtime without restart, globally |
| 212 |
or per process. |
| 213 |
|
| 214 |
Default value is “0” (disabled). |
| 215 |
|
| 216 |
Example 1.1. Set cfgtrace parameter |
| 217 |
... |
| 218 |
modparam("debugger", "cfgtrace", 1) |
| 219 |
... |
| 220 |
|
| 221 |
3.2. cfgtrace_format (int) |
| 222 |
|
| 223 |
Control what is printer in the cfgtrace log message. If it is set to 1, |
| 224 |
then the configuration file path is not printed, making the log |
| 225 |
messages shorter when not including other configuration files in the |
| 226 |
main one. |
| 227 |
|
| 228 |
Default value is “0”. |
| 229 |
|
| 230 |
Example 1.2. Set cfgtrace_format parameter |
| 231 |
... |
| 232 |
modparam("debugger", "cfgtrace_format", 1) |
| 233 |
... |
| 234 |
|
| 235 |
3.3. breakpoint (int) |
| 236 |
|
| 237 |
Control whether every line (global) breakpoint is enabled or disabled |
| 238 |
at startup. |
| 239 |
|
| 240 |
Default value is “0” (disabled). |
| 241 |
|
| 242 |
Example 1.3. Set breakpoint parameter |
| 243 |
... |
| 244 |
modparam("debugger", "breakpoint", 1) |
| 245 |
... |
| 246 |
|
| 247 |
3.4. log_level (int) |
| 248 |
|
| 249 |
What log level is to be used to print module-specific messages. |
| 250 |
|
| 251 |
Default value is “-1” (L_ERR). |
| 252 |
|
| 253 |
Example 1.4. Set log_level parameter |
| 254 |
... |
| 255 |
modparam("debugger", "log_level", 1) |
| 256 |
... |
| 257 |
|
| 258 |
3.5. log_level_name (str) |
| 259 |
|
| 260 |
What log level name is to be used to print cfg trace messages. |
| 261 |
|
| 262 |
Default value is “NULL” (use default log names). |
| 263 |
|
| 264 |
Example 1.5. Set log_level_name parameter |
| 265 |
... |
| 266 |
modparam("debugger", "log_level_name", "exec") |
| 267 |
... |
| 268 |
|
| 269 |
3.6. log_facility (str) |
| 270 |
|
| 271 |
Which log facility is to be used to print module-specific messages. By |
| 272 |
using this setting, you can configure syslog to send debug messages to |
| 273 |
a separate log channel, like a specific kamailio-debug log file. |
| 274 |
|
| 275 |
Default value is “NULL” (default from core). |
| 276 |
|
| 277 |
Example 1.6. Set log_facility parameter |
| 278 |
... |
| 279 |
modparam("debugger", "log_facility", "LOG_DAEMON") |
| 280 |
... |
| 281 |
|
| 282 |
3.7. log_prefix (str) |
| 283 |
|
| 284 |
String to print before any module-specific messages. |
| 285 |
|
| 286 |
Default value is “*** cfgtrace:”. |
| 287 |
|
| 288 |
Example 1.7. Set log_prefix parameter |
| 289 |
... |
| 290 |
modparam("debugger", "log_prefix", "from-debugger-with-love:") |
| 291 |
... |
| 292 |
|
| 293 |
3.8. step_usleep (int) |
| 294 |
|
| 295 |
Microseconds to sleep before checking for new commands when waiting at |
| 296 |
a breakpoint. |
| 297 |
|
| 298 |
Default value is “100000” (that is 0.1 sec). |
| 299 |
|
| 300 |
Example 1.8. Set step_usleep parameter |
| 301 |
... |
| 302 |
modparam("debugger", "step_usleep", 500000) |
| 303 |
... |
| 304 |
|
| 305 |
3.9. step_loops (int) |
| 306 |
|
| 307 |
How many sleeps of 'step_usleep' the RPC process performs when waiting |
| 308 |
for a reply from a worker process before responding to RPC. This avoids |
| 309 |
blocking RPC process forever in case the worker process 'forgets' to |
| 310 |
write back a reply. |
| 311 |
|
| 312 |
Default value is “200”. |
| 313 |
|
| 314 |
Example 1.9. Set step_loops parameter |
| 315 |
... |
| 316 |
modparam("debugger", "step_loops", 100) |
| 317 |
... |
| 318 |
|
| 319 |
3.10. mod_hash_size (int) |
| 320 |
|
| 321 |
Used to compute power of two as size of internal hash table to store |
| 322 |
levels per module (e.g., if it is set to 4, internal hash table has 16 |
| 323 |
slots). One must set its value grater than 0 such that memory to be |
| 324 |
allocated to save the module specific debug levels or facility |
| 325 |
configured by mod_level or mod_facility. This parameter is accessible |
| 326 |
readonly via the Kamailio config framework. |
| 327 |
|
| 328 |
Default value is “0” - feature disabled. |
| 329 |
|
| 330 |
Example 1.10. Set mod_hash_size parameter |
| 331 |
... |
| 332 |
modparam("debugger", "mod_hash_size", 5) |
| 333 |
... |
| 334 |
|
| 335 |
3.11. mod_level_mode (int) |
| 336 |
|
| 337 |
Enable or disable per module log level (0 - disabled, 1 - enabled). |
| 338 |
This parameter is tunable via the Kamailio config framework. To use per |
| 339 |
module log level you also have to set mod_hash_size. |
| 340 |
|
| 341 |
Default value is “0”. |
| 342 |
|
| 343 |
Example 1.11. Set mod_level_mode parameter |
| 344 |
... |
| 345 |
modparam("debugger", "mod_level_mode", 1) |
| 346 |
... |
| 347 |
|
| 348 |
3.12. mod_level (str) |
| 349 |
|
| 350 |
Specify module log level - the value must be in the format: |
| 351 |
modulename=level. The parameter can be set many times. For core log |
| 352 |
level, use module name 'core'. You also must enable mod_level_mode and |
| 353 |
mod_hash_size. |
| 354 |
|
| 355 |
Example 1.12. Set mod_level parameter |
| 356 |
... |
| 357 |
modparam("debugger", "mod_level", "core=3") |
| 358 |
modparam("debugger", "mod_level", "tm=3") |
| 359 |
... |
| 360 |
|
| 361 |
3.13. mod_facility_mode (int) |
| 362 |
|
| 363 |
Enable or disable per module log facility (0 - disabled, 1 - enabled). |
| 364 |
This parameter is tunable via the Kamailio config framework. To use per |
| 365 |
module log facility you also have to set mod_hash_size. |
| 366 |
|
| 367 |
Default value is “0”. |
| 368 |
|
| 369 |
Example 1.13. Set mod_facility_mode parameter |
| 370 |
... |
| 371 |
modparam("debugger", "mod_facility_mode", 1) |
| 372 |
... |
| 373 |
|
| 374 |
3.14. mod_facility (str) |
| 375 |
|
| 376 |
Specify module log facility - the value must be in the format: |
| 377 |
modulename=facility. The parameter can be set many times. For core log |
| 378 |
facility, use module name 'core'. You also must enable |
| 379 |
mod_facility_mode and mod_hash_size. |
| 380 |
|
| 381 |
NOTE: See the syslog() library call for facility names |
| 382 |
(http://linux.die.net/man/3/syslog). The most used facilities are |
| 383 |
LOG_LOCAL[0-7]. |
| 384 |
|
| 385 |
Example 1.14. Set mod_facility parameter |
| 386 |
... |
| 387 |
modparam("debugger", "mod_facility", "core=LOG_LOCAL0") |
| 388 |
modparam("debugger", "mod_facility", "debugger=LOG_LOCAL1") |
| 389 |
... |
| 390 |
|
| 391 |
3.15. log_assign (int) |
| 392 |
|
| 393 |
Enable or disable log assign actions on config (0 - disabled, 1 - |
| 394 |
enabled). |
| 395 |
|
| 396 |
Default value is “0”. |
| 397 |
|
| 398 |
Example 1.15. Set log_assign parameter |
| 399 |
... |
| 400 |
modparam("debugger", "log_assign", 1) |
| 401 |
... |
| 402 |
|
| 403 |
3.16. cfgpkgcheck (int) |
| 404 |
|
| 405 |
If set, before each config action is done pkg memory check, useful to |
| 406 |
detect buffer overflows. |
| 407 |
|
| 408 |
Default value is “0” (disabled). |
| 409 |
|
| 410 |
Example 1.16. Set cfgpkgcheck parameter |
| 411 |
... |
| 412 |
modparam("debugger", "cfgpkgcheck", 1) |
| 413 |
... |
| 414 |
|
| 415 |
3.17. reset_msgid (int) |
| 416 |
|
| 417 |
Used to enable or disable the ability to reset the msgid ($mi) through |
| 418 |
the dbg.reset_msgid RPC command. (0 - disabled, 1 - enabled). |
| 419 |
|
| 420 |
Default value is “0” - feature disabled. |
| 421 |
|
| 422 |
Example 1.17. Set reset_msgid parameter |
| 423 |
... |
| 424 |
modparam("debugger", "reset_msgid", 1) |
| 425 |
... |
| 426 |
|
| 427 |
3.18. cfgtest (int) |
| 428 |
|
| 429 |
Control whether the cfgt module is enabled or disabled at startup. |
| 430 |
Module cfgt needs to be loaded before. |
| 431 |
|
| 432 |
Default value is “0” (disabled). |
| 433 |
|
| 434 |
Example 1.18. Set cfgtest parameter |
| 435 |
... |
| 436 |
loadmodule "cfgt.so" |
| 437 |
modparam("debugger", "cfgtest", 1) |
| 438 |
... |
| 439 |
|
| 440 |
4. Functions |
| 441 |
|
| 442 |
4.1. dbg_breakpoint(mode) |
| 443 |
4.2. dbg_pv_dump([mask] [, level]) |
| 444 |
4.3. dbg_sip_msg([log_level], [facility]) |
| 445 |
|
| 446 |
4.1. dbg_breakpoint(mode) |
| 447 |
|
| 448 |
Anchor a breakpoint at the current line of the config (the one on which |
| 449 |
this function is called). The 'mode' specifies whether the breakpoint |
| 450 |
is enabled (1) or disabled (0) at startup. |
| 451 |
|
| 452 |
Note that this version of the module does not export this anchors to |
| 453 |
RPC for interactive debugging (temporarily disabled). |
| 454 |
|
| 455 |
Example 1.19. dbg_breakpoint usage |
| 456 |
... |
| 457 |
if($si=="10.0.0.10") |
| 458 |
dbg_breakpoint("1"); |
| 459 |
... |
| 460 |
|
| 461 |
4.2. dbg_pv_dump([mask] [, level]) |
| 462 |
|
| 463 |
Prints the content of pv_cache on json format. Defaults are mask=31 and |
| 464 |
level = "L_DBG" |
| 465 |
|
| 466 |
mask - Controls the content to dump: |
| 467 |
* 1 - dump null values |
| 468 |
* 2 - dump avp vars |
| 469 |
* 4 - dump script vars |
| 470 |
* 8 - dump xavp vars |
| 471 |
* 16 - dump DP_OTHER vars |
| 472 |
|
| 473 |
level - The level that will be used in LOG function. It can be: |
| 474 |
* L_ALERT - log level -5 |
| 475 |
* L_BUG - log level -4 |
| 476 |
* L_CRIT - log level -3 |
| 477 |
* L_ERR - log level -1 |
| 478 |
* L_WARN - log level 0 |
| 479 |
* L_NOTICE - log level 1 |
| 480 |
* L_INFO - log level 2 |
| 481 |
* L_DBG - log level 3 |
| 482 |
|
| 483 |
Example 1.20. dbg_pv_dump usage |
| 484 |
... |
| 485 |
$var(temp) = 1; |
| 486 |
$avp(s:more_avp) = 2; |
| 487 |
$avp(s:more_avp) = 3; |
| 488 |
$xavp(x=>more) = "bye"; |
| 489 |
$xavp(x[0]=>more) = "hi"; |
| 490 |
$xavp(x[0]=>other) = 1; |
| 491 |
$xavp(x[0]=>other) = 2; |
| 492 |
$xavp(x=>different) = "foo"; |
| 493 |
$var(empty) = $null; |
| 494 |
|
| 495 |
dbg_pv_dump(30, "L_DBG"); |
| 496 |
... |
| 497 |
|
| 498 |
Output |
| 499 |
... |
| 500 |
4(30943) DEBUG: debugger [debugger_api.c:1613]: dbg_dump_json(): {"$sp":37597," |
| 501 |
$var(rc)":0,"$var(temp)":1,"$avp(more_avp)":[3,2],"$si":"127.0.0.1","$rc":0,"$xa |
| 502 |
vp(x)":[{"different":["foo"]},{"other":[2,1],"more":["hi","bye"]}],"$T_branch_id |
| 503 |
x":0,"$var(empty)":0} |
| 504 |
... |
| 505 |
|
| 506 |
4.3. dbg_sip_msg([log_level], [facility]) |
| 507 |
|
| 508 |
Prints how the sip message would look like if it would be sent out at |
| 509 |
that point in the config(i.e. if the current lump lists would have been |
| 510 |
applied at that point in the config). It also prints a diff list for |
| 511 |
both header and body of sip msg which contain the lump lists content. |
| 512 |
The lumps deleted are printed with "-" sign whereas the lumps added |
| 513 |
have no sign. The config line where the function has been called is |
| 514 |
also printed. |
| 515 |
|
| 516 |
NOTE that dbg_sip_msg function does not modify the initially received |
| 517 |
SIP message. Just displays how it WOULD look like if it were to send it |
| 518 |
at that point. |
| 519 |
|
| 520 |
NOTE that the lump lists are usually applied only once, just before |
| 521 |
sending, to spare message reparse processing. All the changes present |
| 522 |
in lump list are applied on the initially received SIP message. One can |
| 523 |
force the lump application using msg_apply_changes() function from |
| 524 |
textopsx module. |
| 525 |
|
| 526 |
Example 1.21. dbg_sip_msg usage |
| 527 |
... |
| 528 |
dbg_sip_msg(); |
| 529 |
dbg_sip_msg("L_ERR"); |
| 530 |
dbg_sip_msg("L_ERR", "LOG_LOCAL0"); |
| 531 |
... |
| 532 |
|
| 533 |
Output when dbg_sip_msg("L_ERR") is called after append_hf("P-Hint: My |
| 534 |
hint\r\n"); remove_hf("Contact"); |
| 535 |
ERROR: debugger [debugger_mod.c:467]: w_dbg_sip_msg(): CONFIG LINE 338 |
| 536 |
------------------------- START OF SIP message debug -------------------------- |
| 537 |
OPTIONS sip:[email protected] SIP/2.0 |
| 538 |
Via: SIP/2.0/UDP 127.0.1.1:56872;branch=z9hG4bK.6d7c487a;rport;alias |
| 539 |
From: sip:[email protected]:56872;tag=188b7433 |
| 540 |
To: sip:[email protected] |
| 541 |
Call-ID: [email protected] |
| 542 |
CSeq: 1 OPTIONS |
| 543 |
Content-Length: 0 |
| 544 |
Max-Forwards: 70 |
| 545 |
User-Agent: sipsak 0.9.6 |
| 546 |
Accept: text/plain |
| 547 |
P-Hint: My hintt |
| 548 |
|
| 549 |
------------------------------ SIP header diffs ------------------------------- |
| 550 |
- Contact: sip:[email protected]:56872 |
| 551 |
P-Hint: My hint |
| 552 |
------------------------------- SIP body diffs -------------------------------- |
| 553 |
-------------------------- END OF SIP message debug --------------------------- |
| 554 |
|
| 555 |
5. RPC Commands |
| 556 |
|
| 557 |
5.1. dbg.ls |
| 558 |
5.2. dbg.trace |
| 559 |
5.3. dbg.bp |
| 560 |
5.4. dbg.mod_level |
| 561 |
5.5. dbg.reset_msgid |
| 562 |
5.6. dbg.set_mod_level |
| 563 |
5.7. dbg.set_mod_facility |
| 564 |
5.8. dbg.get_mod_level |
| 565 |
5.9. dbg.get_mod_facility |
| 566 |
|
| 567 |
5.1. dbg.ls |
| 568 |
|
| 569 |
List Kamailio processes with info related to interactive debugging. |
| 570 |
|
| 571 |
Name: dbg.list |
| 572 |
|
| 573 |
Parameters: |
| 574 |
* _pid_ : pid for which to list the details. If 'pid' is omitted then |
| 575 |
will print for all processes. |
| 576 |
|
| 577 |
Examples of use with kamcmd: |
| 578 |
dbg.ls |
| 579 |
dbg.ls 1234 |
| 580 |
|
| 581 |
5.2. dbg.trace |
| 582 |
|
| 583 |
Control config script running trace. |
| 584 |
|
| 585 |
Name: dbg.trace |
| 586 |
|
| 587 |
Parameters: |
| 588 |
* _cmd_ : command can be 'on' or 'off' to enable or disable tracing |
| 589 |
for one or all processes. |
| 590 |
* _pid_ : pid for which to list the details. If 'pid' is omitted, |
| 591 |
then details for all processes will be printed. |
| 592 |
|
| 593 |
Examples for using with kamcmd: |
| 594 |
dbg.trace on |
| 595 |
dbg.trace off |
| 596 |
dbg.trace on 1234 |
| 597 |
|
| 598 |
5.3. dbg.bp |
| 599 |
|
| 600 |
Control breakpoints and config execution. |
| 601 |
|
| 602 |
Name: dbg.bp |
| 603 |
|
| 604 |
Parameters: |
| 605 |
* _cmd_ : command, see next section for the list of available values. |
| 606 |
* _pid_ : process id for which to apply the command. If 'pid' is |
| 607 |
omitted, then the inner command will be applied to all processes. |
| 608 |
* _params_ : extra params specific for each command. |
| 609 |
|
| 610 |
Commands: |
| 611 |
* on - turn on breakpoints. Pid parameter is optional. |
| 612 |
* off - turn off breakpoints. Pid parameter is optional. |
| 613 |
* keep - keep breakpoints only for pid given as parameter |
| 614 |
* release - disable breakpoints for processes that are not waiting at |
| 615 |
a breakpoint. Pid parameter is optional. |
| 616 |
* next - run the action under breakpoint and stop at next one (step |
| 617 |
by step execution). Pid parameter is mandatory. |
| 618 |
* move - run the action under breakpoint and remove the rest of |
| 619 |
breakpoints (continue execution without stopping again at next |
| 620 |
actions). Pid parameter is mandatory. |
| 621 |
* show - print details about the current breakpoint for pid. Pid |
| 622 |
parameter is mandatory. |
| 623 |
* eval - evaluate a pseudo-variable and print the result in RPC Pid |
| 624 |
parameter is mandatory. |
| 625 |
* log - evaluate a pseudo-variable and print the result in SIP router |
| 626 |
logs. Pid parameter is mandatory. |
| 627 |
|
| 628 |
Examples for using with kamcmd: |
| 629 |
dbg.bp off |
| 630 |
dbg.bp on |
| 631 |
dbg.bp release |
| 632 |
dbg.bp on 1234 |
| 633 |
dbg.bp eval 1234 $fu |
| 634 |
dbg.bp move 1234 |
| 635 |
|
| 636 |
5.4. dbg.mod_level |
| 637 |
|
| 638 |
Specify module log level. |
| 639 |
|
| 640 |
Name: dbg.mod_level |
| 641 |
|
| 642 |
Parameters: |
| 643 |
* _module_ : For core log level, use module name 'core' |
| 644 |
* _level_ : integer |
| 645 |
|
| 646 |
Examples of use with kamcmd: |
| 647 |
dbg.mod_level core 3 |
| 648 |
dbg.mod_level tm 3 |
| 649 |
|
| 650 |
5.5. dbg.reset_msgid |
| 651 |
|
| 652 |
Resets the message sequence ($mi). Internally there is no real change. |
| 653 |
This can be useful for unit test cases in order to be able to replicate |
| 654 |
exactly the same kamailio output. You need to set the debugger |
| 655 |
parameter reset_msgid to 1 to activate this functionality. |
| 656 |
|
| 657 |
Name: dbg.reset_msgid |
| 658 |
|
| 659 |
Examples of use with kamcmd: |
| 660 |
dbg.reset_msgid |
| 661 |
|
| 662 |
5.6. dbg.set_mod_level |
| 663 |
|
| 664 |
Set the module log level. If module does not exist in kamailio, the |
| 665 |
entry in the level hashtable is still added for the bogus module. |
| 666 |
|
| 667 |
Name: dbg.set_mod_level |
| 668 |
|
| 669 |
Examples of use with kamcmd: |
| 670 |
dbg.set_mod_level core 1 |
| 671 |
|
| 672 |
5.7. dbg.set_mod_facility |
| 673 |
|
| 674 |
Set the module log facility. If module does not exist in kamailio, the |
| 675 |
entry in the facility hashtable is still added for the bogus module. |
| 676 |
|
| 677 |
Name: dbg.set_mod_facility |
| 678 |
|
| 679 |
Examples of use with kamcmd: |
| 680 |
dbg.set_mod_facility core LOG_LOCAL1 |
| 681 |
|
| 682 |
5.8. dbg.get_mod_level |
| 683 |
|
| 684 |
Get the module log level. If mod_name does not exist in the level |
| 685 |
hashtable, returns the config file value. |
| 686 |
|
| 687 |
Name: dbg.get_mod_level |
| 688 |
|
| 689 |
Examples of use with kamcmd: |
| 690 |
dbg.get_mod_level core |
| 691 |
|
| 692 |
5.9. dbg.get_mod_facility |
| 693 |
|
| 694 |
Get the module log facility. If mod_name does not exist in the facility |
| 695 |
hashtable, returns the config file value. |
| 696 |
|
| 697 |
Name: dbg.get_mod_facility |
| 698 |
|
| 699 |
Examples of use with kamcmd: |
| 700 |
dbg.get_mod_facility core |
| 701 |
|
| 702 |
6. Usage |
| 703 |
|
| 704 |
A common usage is to investigate the execution path for a specific SIP |
| 705 |
message. Just enable cfg running trace, send the message and watch the |
| 706 |
logs. |
| 707 |
|
| 708 |
Another typical usage is to do interactive debugging and run each line |
| 709 |
of the route blocks of the configuration file step-by-step for a |
| 710 |
particular SIP message. |
| 711 |
|
| 712 |
You need to connect using kamcmd (or other RPC client) to Kamailio. |
| 713 |
Then you can enable cfg breakpoints and send the SIP message. One |
| 714 |
process will be in waiting state ('state' field different than 0 when |
| 715 |
you do dbg.ls). Calling dbg.release will set the other Kamailio |
| 716 |
processes in no-breakpoint mode so they can process other SIP messages |
| 717 |
without need to interact with them. |
| 718 |
|
| 719 |
A process blocked at a breakpoint is waiting for a command. Use 'dbg.bp |
| 720 |
next pid' to execute the current action and stop at the next one. |
| 721 |
'dbg.bp eval pid PV' can be used to retrieve the value of PV. Once you |
| 722 |
are done and want to continue the execution of the config without |
| 723 |
interaction use 'dbg.bp move pid'. |
| 724 |
|
| 725 |
Example of a session: |
| 726 |
... |
| 727 |
kamcmd> dbg.ls |
| 728 |
{ |
| 729 |
entry: 0 |
| 730 |
pid: 6393 |
| 731 |
set: 3 |
| 732 |
state: 0 |
| 733 |
in.pid: 0 |
| 734 |
in.cmd: 0 |
| 735 |
} |
| 736 |
{ |
| 737 |
entry: 1 |
| 738 |
pid: 6394 |
| 739 |
set: 3 |
| 740 |
state: 0 |
| 741 |
in.pid: 0 |
| 742 |
in.cmd: 0 |
| 743 |
} |
| 744 |
... |
| 745 |
{ |
| 746 |
entry: 9 |
| 747 |
pid: 6402 |
| 748 |
set: 3 |
| 749 |
state: 1 |
| 750 |
in.pid: 0 |
| 751 |
in.cmd: 0 |
| 752 |
} |
| 753 |
|
| 754 |
kamcmd> dbg.bp show 6402 |
| 755 |
at bkp [/etc/kamailio/debugger.cfg:369] a=6 n=route |
| 756 |
|
| 757 |
kamcmd> dbg.bp next 6402 |
| 758 |
exec [/etc/kamailio/debugger.cfg:369] a=6 n=route |
| 759 |
|
| 760 |
kamcmd> dbg.bp next 6402 |
| 761 |
exec [/etc/kamailio/debugger.cfg:462] a=17 n=if |
| 762 |
|
| 763 |
kamcmd> dbg.bp eval 6402 $fu |
| 764 |
$fu : t=str v=sip:[email protected] |
| 765 |
|
| 766 |
kamcmd> dbg.bp move 6402 |
| 767 |
200 ok |
| 768 |
... |
| 769 |
|
| 770 |
Running the config trace looks like: |
| 771 |
... |
| 772 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=368 a=6 n=route |
| 773 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=461 a=17 n=if |
| 774 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=456 a=26 n=mf_pro |
| 775 |
cess_maxfwd_header |
| 776 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=466 a=17 n=if |
| 777 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=461 a=27 n=sanity |
| 778 |
_check |
| 779 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=371 a=6 n=route |
| 780 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=659 a=3 n=return |
| 781 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=374 a=6 n=route |
| 782 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=501 a=17 n=if |
| 783 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=470 a=25 n=has_to |
| 784 |
tag |
| 785 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=386 a=17 n=if |
| 786 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=379 a=26 n=is_met |
| 787 |
hod |
| 788 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=386 a=25 n=t_chec |
| 789 |
k_trans |
| 790 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=389 a=6 n=route |
| 791 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=643 a=3 n=return |
| 792 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=393 a=26 n=remove |
| 793 |
_hf |
| 794 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=398 a=17 n=if |
| 795 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=394 a=26 n=is_met |
| 796 |
hod |
| 797 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=404 a=17 n=if |
| 798 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=398 a=26 n=is_met |
| 799 |
hod |
| 800 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=404 a=6 n=route |
| 801 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=682 a=17 n=if |
| 802 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=409 a=6 n=route |
| 803 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=575 a=17 n=if |
| 804 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=550 a=26 n=is_met |
| 805 |
hod |
| 806 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=551 a=3 n=return |
| 807 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=412 a=6 n=route |
| 808 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=518 a=17 n=if |
| 809 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=505 a=26 n=is_met |
| 810 |
hod |
| 811 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=513 a=17 n=if |
| 812 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=507 a=42 n=isflag |
| 813 |
set |
| 814 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=516 a=17 n=if |
| 815 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=513 a=26 n=save |
| 816 |
9(6285) ERROR: *** cfgtrace: c=[/etc/kamailio/debugger.cfg] l=516 a=3 n=exit |
| 817 |
... |
| 818 |
|
| 819 |
The above example is for a registration with default config for version |
| 820 |
3.1.0, without authentication. Listed fields are: 'c' - config file; |
| 821 |
'l' - line; 'a' - internal action id; 'n' - name of executed action. |
| 822 |
'ERROR' prefix is printed because these messages were sent to the L_ERR |
| 823 |
log level. |