2

I have written a small simulation program using python 3.5.2 and PyQt5. I was previously using PyQt4 and had issues with intermittent segmentation faults occurring inside Qt. For this reason, testing required the program to be run about 20 times to make sure the fault didn't occur.

Now I would like to know if there is a simple way to write a script that I can run using gdb run which would do something like:

for i in range(20):
    run MyProgram.py
    wait(startup time)
    input keyboard commands with appropriate intervals

    wait for program to run
    if error occurs:
        force kill MyProgram.py
        continue loop
    elif runtime > some value:
        input more keyboard commands
        continue loop

Is there a way to do this without installing any costly software?

Kajsa
  • 211
  • 1
  • 16
  • Why do you want to run the script inside gdb? You can test it without gdb the same way. – ks1322 Apr 05 '18 at 16:46
  • @ks1322 Running it in gdb gives me the opportunity to run `traceback` and save the output to a log file for later. I'm not sure how to do this without gdb. – Kajsa Apr 05 '18 at 20:11

1 Answers1

0

testing required the program to be run about 20 times to make sure the fault didn't occur

You does not have to test the program inside gdb only because you want to see backtrace if it is crashed. Normally if the program receives SIGSEGV signal, program's process is terminated and core is dumped. Later you can open core dump in gdb and see backtrace of crashed process:

gdb program core
...
(gdb) bt
...

See How to generate a core dump in Linux when a process gets a segmentation fault? how to enable core dump saving on Linux.

ks1322
  • 33,961
  • 14
  • 109
  • 164