Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Now emit manifest constant values to the debugger.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Sep 17, 2013
1 parent 021dda8 commit 6b40c48
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
members for correct debugging.
* d-objfile.cc(build_type_decl): Use fully qualified type name in
debugging code.
(VarDeclaration::toObjFile): Emit manifest constant values in debug
code generation.

2013-09-10 Iain Buclaw <ibuclaw@gdcproject.org>

Expand Down
3 changes: 2 additions & 1 deletion gcc/d/d-elem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,8 @@ FuncExp::toElem (IRState *irs)
}

// Emit after current function body has finished.
irs->func->deferred.push (fd);
if (irs->func)
irs->func->deferred.push (fd);

// If nested, this will be a trampoline...
if (fd->isNested())
Expand Down
43 changes: 41 additions & 2 deletions gcc/d/d-objfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,48 @@ VarDeclaration::toObjFile (int)
return;
}

// Do not store variables we cannot take the address of
// Do not store variables we cannot take the address of,
// but keep the values for purposes of debugging.
if (!canTakeAddressOf())
return;
{
Expression *ie = NULL;
tree ctype = declaration_type (this);
tree ident;

if (toParent2()->isModule())
ident = get_identifier (toPrettyChars());
else
ident = get_identifier (toChars());

tree decl = build_decl (UNKNOWN_LOCATION, VAR_DECL, ident, ctype);
set_decl_location (decl, this);

if (init)
{
gcc_assert (!init->isVoidInitializer());
ie = init->toExpression();
}
else
ie = type->defaultInit();

gcc_assert (ie != NULL);
DECL_INITIAL (decl) = ie->toElem (current_irstate);

// Manifest constants have no address in memory.
TREE_CONSTANT (decl) = 1;
TREE_READONLY (decl) = 1;
TREE_STATIC (decl) = 0;

d_pushdecl (decl);
d_keep (decl);

bool toplevel = !DECL_CONTEXT (decl);
if (toplevel)
d_add_global_declaration (decl);

rest_of_decl_compilation (decl, toplevel, 0);
return;
}

if (isDataseg() && !(storage_class & STCextern))
{
Expand Down

0 comments on commit 6b40c48

Please sign in to comment.