Reputation: 1045
I am trying to step through a python script for some code I wrote over a year ago. The way I recall, when you write a pdb.set_trace() line, the program will halt its execution at that point and print the next line that will be executed. Entering 'n' or 's' will advance the execution by a line (and maybe step into a function, not too relevant to my problem) AND print the next line to be executed again.
Now, I have one program "example1.py" and it is not printing the next statement to be executed. I just get some output like the following
./example1.py
> /home/some/example1.py(44)create()
(Pdb) s
> /home/some/example1.py(45)create()
(Pdb) s
--Call--
> /home/some/example1.py(90)parse()
But when I try this same thing with a different python program, "example2.py", one that I wrote more recently I am getting the output I expect (the next statement to be executed.)
> /home/some/example2.py(86)random_update()
-> DATE_LIMIT=1
(Pdb) n
> /home/some/example2.py(87)random_update()
-> FILE_LIMIT=120
(Pdb) n
> /home/some/example2.py(89)random_update()
-> n_dates=0
I have no idea what could be a possible cause for this. Could import statements interfere with pdb's execution?
UPDATE: So I set my trace breakpoint before changing to a directory that is outside my home directory. When I do this, I get the output that I expect. I noticed that this directory's group owner was root so I changed it to my user. This didn't resolve my problem, but now I know it has to do with the program execution location.
Upvotes: 0
Views: 189
Reputation: 1045
I figured it out. If I set my trace before a line that changes the current directory to a directory where the program is not located, I was getting the output I expected. Once I set the trace after this directory change, I was no longer getting statement execution output.
To resolve this, I executed the program with a full path
python /home/name/home/some/example1.py
Upvotes: 1