'Run gdb and have cygdb import the debug information from the code
defined in TestParseTreeTransforms\'s setUp method'

def setUp(self):

    if (not test_gdb()):
        return
    self.tempdir = tempfile.mkdtemp()
    self.destfile = os.path.join(self.tempdir, 'codefile.pyx')
    self.debug_dest = os.path.join(self.tempdir, 'cython_debug', 'cython_debug_info_codefile')
    self.cfuncs_destfile = os.path.join(self.tempdir, 'cfuncs')
    self.cwd = os.getcwd()
    try:
        os.chdir(self.tempdir)
        shutil.copy(codefile, self.destfile)
        shutil.copy(cfuncs_file, (self.cfuncs_destfile + '.c'))
        shutil.copy(cfuncs_file.replace('.c', '.h'), (self.cfuncs_destfile + '.h'))
        compiler = ccompiler.new_compiler()
        compiler.compile(['cfuncs.c'], debug=True, extra_postargs=['-fPIC'])
        opts = dict(test_directory=self.tempdir, module='codefile')
        optimization_disabler = build_ext.Optimization()
        cython_compile_testcase = runtests.CythonCompileTestCase(workdir=self.tempdir, cleanup_workdir=False, tags=runtests.parse_tags(codefile), **opts)
        new_stderr = open(os.devnull, 'w')
        stderr = sys.stderr
        sys.stderr = new_stderr
        optimization_disabler.disable_optimization()
        try:
            cython_compile_testcase.run_cython(targetdir=self.tempdir, incdir=None, annotate=False, extra_compile_options={'gdb_debug': True, 'output_dir': self.tempdir}, **opts)
            cython_compile_testcase.run_distutils(incdir=None, workdir=self.tempdir, extra_extension_args={'extra_objects': ['cfuncs.o']}, **opts)
        finally:
            optimization_disabler.restore_state()
            sys.stderr = stderr
            new_stderr.close()
    except:
        os.chdir(self.cwd)
        raise
