Skip to content

Commit

Permalink
Merge pull request #5300 from WalterBright/dwarfehbugs
Browse files Browse the repository at this point in the history
Dwarf EH: complete the table generation
  • Loading branch information
9rnsr committed Dec 7, 2015
2 parents 539d87c + 81846ea commit 4afb98f
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 126 deletions.
10 changes: 9 additions & 1 deletion src/backend/cgcod.c
Expand Up @@ -28,6 +28,7 @@
#include "type.h"
#include "exh.h"
#include "xmm.h"
#include "dwarf.h"

static char __file__[] = __FILE__; /* for tassert.h */
#include "tassert.h"
Expand Down Expand Up @@ -527,10 +528,17 @@ void codgen()
// Do this before code is emitted because we patch some instructions
nteh_gentables();
}
if (usednteh & EHtry)
if (usednteh & EHtry && // saw BCtry or BC_try (test EHcleanup too?)
config.ehmethod == EH_DM)
{
except_gentables();
}
if (config.ehmethod == EH_DWARF)
{
funcsym_p->Sfunc->Fstartblock = startblock;
dwarf_except_gentables(funcsym_p, startoffset, retoffset);
funcsym_p->Sfunc->Fstartblock = NULL;
}
#endif

#if SCPP
Expand Down
9 changes: 6 additions & 3 deletions src/backend/cod3.c
Expand Up @@ -2997,7 +2997,8 @@ code* prolog_frame(unsigned farfunc, unsigned* xlocalsize, bool* enter)
// by nteh_prolog()
}
#endif
if (config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D)
if (config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D ||
config.ehmethod == EH_DWARF)
{ int off = 2 * REGSIZE;
dwarf_CFA_set_loc(1); // address after PUSH EBP
dwarf_CFA_set_reg_offset(SP, off); // CFA is now 8[ESP]
Expand Down Expand Up @@ -3169,7 +3170,8 @@ code* prolog_saveregs(code *c, regm_t topush)
}
if (I64)
code_orrex(c, REX_W);
if (config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D)
if (config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D ||
config.ehmethod == EH_DWARF)
{ // Emit debug_frame data giving location of saved register
pinholeopt(c, NULL);
dwarf_CFA_set_loc(calcblksize(c)); // address after save
Expand Down Expand Up @@ -3199,7 +3201,8 @@ code* prolog_saveregs(code *c, regm_t topush)
c = genpush(c, reg);
EBPtoESP += REGSIZE;
spoff += REGSIZE;
if (config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D)
if (config.fulltypes == CVDWARF_C || config.fulltypes == CVDWARF_D ||
config.ehmethod == EH_DWARF)
{ // Emit debug_frame data giving location of saved register
// relative to 0[EBP]
pinholeopt(c, NULL);
Expand Down
4 changes: 2 additions & 2 deletions src/backend/code.h
Expand Up @@ -164,8 +164,8 @@ extern unsigned usednteh;
#define NTEHcleanup 8 // destructors need to be called
#define NTEHtry 0x10 // had C++ try statement
#define NTEHcpp (NTEHexcspec | NTEHcleanup | NTEHtry)
#define EHcleanup 0x20
#define EHtry 0x40
#define EHcleanup 0x20 // has destructors in the 'code' instructions
#define EHtry 0x40 // has BCtry or BC_try blocks
#define NTEHjmonitor 0x80 // uses Mars monitor
#define NTEHpassthru 0x100

Expand Down

0 comments on commit 4afb98f

Please sign in to comment.