Bug 894 - ./waf --run error message upon segfault
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Fri, 23 Apr 2010 15:55:15 +0100
changeset 627577f833c7ddae
parent 6274 3e8b3f2306c9
child 6276 3b7ec0d36079
Bug 894 - ./waf --run error message upon segfault
wutils.py
     1.1 --- a/wutils.py	Fri Apr 23 15:46:46 2010 +0100
     1.2 +++ b/wutils.py	Fri Apr 23 15:55:15 2010 +0100
     1.3 @@ -147,7 +147,20 @@
     1.4              except WindowsError, ex:
     1.5                  raise Utils.WafError("Command %s raised exception %s" % (argv, ex))
     1.6      if retval:
     1.7 -        raise Utils.WafError("Command %s exited with code %i" % (argv, retval))
     1.8 +        signame = None
     1.9 +        if retval < 0: # signal?
    1.10 +            import signal
    1.11 +            for name, val in vars(signal).iteritems():
    1.12 +                if len(name) > 3 and name[:3] == 'SIG' and name[3] != '_':
    1.13 +                    if val == -retval:
    1.14 +                        signame = name
    1.15 +                        break
    1.16 +        if signame:
    1.17 +            raise Utils.WafError("Command %s terminated with signal %s."
    1.18 +                                 " Run it under a debugger to get more information "
    1.19 +                                 "(./waf --run <program> --command-template=\"gdb --args %%s <args>\")." % (argv, signame))
    1.20 +        else:
    1.21 +            raise Utils.WafError("Command %s exited with code %i" % (argv, retval))
    1.22      return retval
    1.23  
    1.24  def get_run_program(program_string, command_template=None):