Gdb usage: setting more breakpoints whilst running

I am able to hit a break point.

Executing import torch runs for 10s of seconds. If I Ctrl-c to stop execution; I have to re-import on the next run; which again takes some time.

Is there a way to be able to set more breakpoints without having to stop the run?

You can set new breakpoints in gdb while you are debugging as described here. E.g. break filename:linenumber will add a new breakpoint which will be hit if you continue the execution in gdb.

Sorry for my slow response; and probably for the very basic question; but to double check I’m not missing something. The below console output shows the error I get trying to set a “break” after run.

I think the >>> indicates I’m inputting to a python interpreter; so makes sense the gdb commands aren’t going to have an affect there. But if I ctr-c out of the running program; I have to re-import; which is just a bit slow

root@brent:/home/brent/repos/pytorch# gdb python
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
(gdb) break at::Tensor::neg
(gdb) run
Starting program: /opt/conda/bin/python 
>>> break at::Tensor::neg
  File "<stdin>", line 1
    break at::Tensor::neg
SyntaxError: invalid syntax
>>> import torch

AHHHHH - but once I’ve hit a breakpoint; I’m back in the hands of gdb – and then seem able to set more breakpoints.