herlesupreeth / docker_open5gs

Docker files to run open5gs + IMS + eNB + gNB + NR-UE in a docker
BSD 2-Clause "Simplified" License
302 stars 170 forks source link

How to debug kamailio_pcscf using gdb #347

Open lglhust opened 1 month ago

lglhust commented 1 month ago

Hi herlesupreeth: I use "kamailio -f /etc/kamailio_pcscf/kamailio_pcscf.cfg -P /kamailio_pcscf.pid -DD -E -e" to load kamailio_pcscf . I don't how to debug kamailio_pcscf with gdb.

Thanks. 
herlesupreeth commented 1 month ago

You can use the below diff

diff --git a/ims_base/kamailio_init.sh b/ims_base/kamailio_init.sh
index d48ad37..5618fe6 100755
--- a/ims_base/kamailio_init.sh
+++ b/ims_base/kamailio_init.sh
@@ -42,10 +42,11 @@ elif [[ "$COMPONENT_NAME" =~ ^(scscf-[[:digit:]]+$) ]]; then
        kamailio -f /etc/kamailio_scscf/kamailio_scscf.cfg -P /kamailio_scscf.pid -DD -E -e
 elif [[ "$COMPONENT_NAME" =~ ^(pcscf-[[:digit:]]+$) ]]; then
        echo "Deploying component: '$COMPONENT_NAME'"
+       apt-get install -y gdb && \
        /mnt/pcscf/pcscf_init.sh && \
        mkdir -p /var/run/kamailio_pcscf && \
        rm -f /kamailio_pcscf.pid && \
-       kamailio -f /etc/kamailio_pcscf/kamailio_pcscf.cfg -P /kamailio_pcscf.pid -DD -E -e
+       gdb --args kamailio -f /etc/kamailio_pcscf/kamailio_pcscf.cfg -P /kamailio_pcscf.pid -DD -E -e
 elif [[ "$COMPONENT_NAME" =~ ^(smsc-[[:digit:]]+$) ]]; then
        echo "Deploying component: '$COMPONENT_NAME'"
        /mnt/smsc/smsc_init.sh && \
NUCLEAR-WAR commented 1 month ago

Hi @lglhust,

If your plan is to open a Ticket in Kamailio repo, then you need to do this in the Container terminal :

docker exec -it kamailio_container /bin/bash

ulimit -c unlimited sysctl -w kernel.core_pattern=core

the coredump will be in the root /

make sure that gdb tool is installed

after that you need to read teh coredump on the conainer, sending teh coredump to someone will not help, it must be done on the same machine with the same problematic code that need to be debugged: like that

gdb bt full and copy the whole output

Best regards

lglhust commented 1 month ago

Thanks a lot.