Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ddmd/backend/cgcv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ unsigned cv4_typidx(type *t)
{
// This is a hack to duplicate bugs in VC, so that the VC
// debugger will work.
tymnext = t->Tnext->Tty;
tymnext = t->Tnext ? t->Tnext->Tty : TYint;
if (tymnext & (mTYconst | mTYimmutable | mTYvolatile) &&
!tycv &&
tyarithmetic(tymnext) &&
Expand Down
1 change: 1 addition & 0 deletions src/ddmd/globals.d
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ struct Param
bool vfield; // identify non-mutable field variables
bool vcomplex; // identify complex/imaginary type usage
ubyte symdebug; // insert debug symbolic information
bool symdebugref; // insert debug information for all referenced types, too
bool alwaysframe; // always emit standard stack frame
bool optimize; // run optimizer
bool map; // generate linker .map file
Expand Down
1 change: 1 addition & 0 deletions src/ddmd/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct Param
bool vfield; // identify non-mutable field variables
bool vcomplex; // identify complex/imaginary type usage
char symdebug; // insert debug symbolic information
bool symdebugref; // insert debug information for all referenced types, too
bool alwaysframe; // always emit standard stack frame
bool optimize; // run optimizer
bool map; // generate linker .map file
Expand Down
7 changes: 7 additions & 0 deletions src/ddmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Where:
-dip25 implement http://wiki.dlang.org/DIP25 (experimental)
-dip1000 implement http://wiki.dlang.org/DIP1000 (experimental)
-g add symbolic debug info
-gf emit debug info for all referenced types
-gs always emit stack frame
-gx add stack stomp code
-H generate 'header' file
Expand Down Expand Up @@ -470,6 +471,12 @@ private int tryMain(size_t argc, const(char)** argv)
deprecation(loc, "use -g instead of -gc");
global.params.symdebug = 2;
}
else if (strcmp(p + 1, "gf") == 0)
{
if (!global.params.symdebug)
global.params.symdebug = 1;
global.params.symdebugref = true;
}
else if (strcmp(p + 1, "gs") == 0)
global.params.alwaysframe = true;
else if (strcmp(p + 1, "gx") == 0)
Expand Down
43 changes: 33 additions & 10 deletions src/ddmd/toctype.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ddmd.globals;
import ddmd.glue;
import ddmd.id;
import ddmd.mtype;
import ddmd.tocvdebug;
import ddmd.visitor;

extern (C++) final class ToCtypeVisitor : Visitor
Expand Down Expand Up @@ -143,6 +144,10 @@ public:
symbol_struct_addField(cast(Symbol*)t.ctype.Ttag, v.ident.toChars(), Type_toCtype(v.type), v.offset);
}
}

if (global.params.symdebugref)
toDebug(sym);

return;
}

Expand Down Expand Up @@ -176,6 +181,10 @@ public:
{
t.ctype = Type_toCtype(t.sym.memtype);
}

if (global.params.symdebugref)
toDebug(t.sym);

return;
}

Expand All @@ -194,25 +203,39 @@ public:
}
else
t.ctype = mctype;

//printf("t = %p, Tflags = x%x\n", t, t.Tflags);
}

override void visit(TypeClass t)
{
//printf("TypeClass::toCtype() %s\n", toChars());
type* tc = type_struct_class(t.sym.toPrettyChars(true), t.sym.alignsize, t.sym.structsize, null, null, false, true, true);
t.ctype = type_pointer(tc);
/* Add in fields of the class
* (after setting ctype to avoid infinite recursion)
*/
if (global.params.symdebug)
if (t.mod == 0)
{
for (size_t i = 0; i < t.sym.fields.dim; i++)
//printf("TypeClass::toCtype() %s\n", toChars());
type* tc = type_struct_class(t.sym.toPrettyChars(true), t.sym.alignsize, t.sym.structsize, null, null, false, true, true);
t.ctype = type_pointer(tc);
/* Add in fields of the class
* (after setting ctype to avoid infinite recursion)
*/
if (global.params.symdebug)
{
VarDeclaration v = t.sym.fields[i];
symbol_struct_addField(cast(Symbol*)tc.Ttag, v.ident.toChars(), Type_toCtype(v.type), v.offset);
for (size_t i = 0; i < t.sym.fields.dim; i++)
{
VarDeclaration v = t.sym.fields[i];
symbol_struct_addField(cast(Symbol*)tc.Ttag, v.ident.toChars(), Type_toCtype(v.type), v.offset);
}
}

if (global.params.symdebugref)
toDebug(t.sym);
return;
}

// Copy mutable version of backend type and add modifiers
type* mctype = Type_toCtype(t.castMod(0));
t.ctype = type_alloc(tybasic(mctype.Tty)); // pointer to class instance
t.ctype.Tcount++;
addMod(t);
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/ddmd/tocvdebug.d
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import ddmd.globals;
import ddmd.id;
import ddmd.mtype;
import ddmd.target;
import ddmd.toctype;
import ddmd.visitor;

import ddmd.backend.cc;
Expand All @@ -51,10 +52,6 @@ import ddmd.backend.type;

extern (C++):


type *Type_toCtype(Type t);
int cvMember(Dsymbol s, ubyte *p);

/* The CV4 debug format is defined in:
* "CV4 Symbolic Debug Information Specification"
* rev 3.1 March 5, 1993
Expand Down Expand Up @@ -855,8 +852,10 @@ int cvMember(Dsymbol s, ubyte *p)
{
//printf("FuncDeclaration.cvMember() '%s'\n", fd.toChars());

if (!fd.type) // if not compiled in,
return; // skip it
if (!fd.type) // if not compiled in,
return; // skip it
if (!fd.type.nextOf()) // if not fully analyzed (e.g. auto return type)
return; // skip it

const id = fd.toChars();

Expand Down
17 changes: 13 additions & 4 deletions src/ddmd/toobj.d
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import ddmd.statement;
import ddmd.staticassert;
import ddmd.target;
import ddmd.tocsym;
import ddmd.toctype;
import ddmd.tocvdebug;
import ddmd.todt;
import ddmd.tokens;
Expand Down Expand Up @@ -327,7 +328,9 @@ void toObjFile(Dsymbol ds, bool multiobj)
return;
}

if (global.params.symdebug)
if (global.params.symdebugref)
Type_toCtype(cd.type); // calls toDebug() only once
else if (global.params.symdebug)
toDebug(cd);

assert(cd.semanticRun >= PASSsemantic3done); // semantic() should have been run to completion
Expand Down Expand Up @@ -646,7 +649,9 @@ void toObjFile(Dsymbol ds, bool multiobj)
if (!id.members)
return;

if (global.params.symdebug)
if (global.params.symdebugref)
Type_toCtype(id.type); // calls toDebug() only once
else if (global.params.symdebug)
toDebug(id);

enum_SC scclass = SCcomdat;
Expand Down Expand Up @@ -828,7 +833,9 @@ void toObjFile(Dsymbol ds, bool multiobj)
// do not output forward referenced structs's
if (!sd.isAnonymous() && sd.members)
{
if (global.params.symdebug)
if (global.params.symdebugref)
Type_toCtype(sd.type); // calls toDebug() only once
else if (global.params.symdebug)
toDebug(sd);

genTypeInfo(sd.type, null);
Expand Down Expand Up @@ -987,7 +994,9 @@ void toObjFile(Dsymbol ds, bool multiobj)
if (ed.isAnonymous())
return;

if (global.params.symdebug)
if (global.params.symdebugref)
Type_toCtype(ed.type); // calls toDebug() only once
else if (global.params.symdebug)
toDebug(ed);

genTypeInfo(ed.type, null);
Expand Down
Loading