diff options
author | Filip Tehlar <ftehlar@cisco.com> | 2023-02-28 18:59:15 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2023-03-02 17:34:24 +0000 |
commit | ec5c40b83acae400a8cc1a18ad897b6365774559 (patch) | |
tree | c5278180af04a1e866c3dbe95a3fed46d93a4aa0 /extras/hs-test/vppinstance.go | |
parent | 2da99e50722f258618fa5fe53f93e603c97d4fe3 (diff) |
hs-test: add support for running vpp in gdb
Type: test
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Change-Id: I6e03b88ca013cafd73f424ea63f706f105bebe6b
Diffstat (limited to 'extras/hs-test/vppinstance.go')
-rw-r--r-- | extras/hs-test/vppinstance.go | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/extras/hs-test/vppinstance.go b/extras/hs-test/vppinstance.go index 4092d35cfd6..1c28ec920b7 100644 --- a/extras/hs-test/vppinstance.go +++ b/extras/hs-test/vppinstance.go @@ -3,8 +3,11 @@ package main import ( "fmt" "github.com/edwarnicke/exechelper" + "os" "os/exec" + "os/signal" "strings" + "syscall" "time" "go.fd.io/govpp" @@ -113,8 +116,27 @@ func (vpp *VppInstance) start() error { startupFileName := vpp.getEtcDir() + "/startup.conf" vpp.container.createFile(startupFileName, configContent) - // Start VPP - vpp.container.execServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"") + if *IsVppDebug { + sig := make(chan os.Signal, 1) + signal.Notify(sig, syscall.SIGINT) + cont := make(chan bool, 1) + go func() { + sig := <-sig + fmt.Println(sig) + cont <- true + }() + + // Start VPP in GDB and wait for user to attach it + vpp.container.execServer("su -c \"gdb -ex run --args vpp -c " + startupFileName + " &> /proc/1/fd/1\"") + fmt.Println("run following command in different terminal:") + fmt.Println("docker exec -it " + vpp.container.name + " gdb -ex \"attach $(docker exec " + vpp.container.name + " pidof gdb)\"") + fmt.Println("Afterwards press CTRL+C to continue") + <-cont + fmt.Println("continuing...") + } else { + // Start VPP + vpp.container.execServer("su -c \"vpp -c " + startupFileName + " &> /proc/1/fd/1\"") + } // Connect to VPP and store the connection sockAddress := vpp.container.GetHostWorkDir() + defaultApiSocketFilePath |