Remote Debugging using gdbserver
Don't worry, 'remote debugging' can help you survive. Remote debugging is a two-step process:
Start gdbserver on the machine where the process to debug is running.Gdbserver is a utility that that allows remote connections over TCP using standard gdb remote serial protocol. You need to specify a free port where gdbserver can listen, e.g.
pankaj@ubuntu:~$ gdbserver :1111 <executable path> <command line arguments>
Run gdb remotely from client
Now use gdb from the other machine where you have the source code:
pankaj@ubuntu:~$ gdb <executable path>
Once you get the gdb prompt, use the ip address and port of the machine where gdbserver is running to connect to it and start interactive debugging session:
(gdb) target machine <ip_address>:<port>
To know more about such programming practices followed in industry, do grab a copy of my book - "Hello World: Student to Software Professional” published by Partridge (A Penguin Random House Company). Now available worldwide on all the MAJOR ONLINE Stores - Amazon, Google Play, Flipkart, Barnes & Noble and many others.