Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Ddwarf #526

Merged
merged 4 commits into from

5 participants

Martin Nowak Walter Bright Mathias L. Baumann Vladimir Panteleev Leandro Lucarella
Martin Nowak
Collaborator
  • emit debug infos for dynamic arrays as
    struct _Array_T { size_t length; T* ptr; }

  • emit debug infos for delegates as
    struct _Delegate{ void* ctxptr; Function* funcptr; }

  • emit debug infos for aarrays as
    struct _AArray_KeyT_ValueT { void* ptr; }

  • remove D DWARF extensions

  • remove dead code in toctype.c which changed the ctype to
    structs, the backend could not handle them

  • emit same debug infos for -gc as the info is common C

Specifically the _Array_T type will hook to gdb's D support.
That is with gdb >= 2010-04-29 this will add full dynamic
array printing support.

The function pointer in _Delegate is correctly typed and
will be resolved to the actual symbol name during debugging.

For AAs we can't really add debug infos as their implementation
is hidden in druntime.

Walter Bright

I'd rather #ifdef the D Dwarf extensions out, rather than remove them.

I'd also rather leave in the struct generation stuff as #ifdef, as it is useful for Codeview symbolic debug info generation, though that needs to be looked at in more detail.

Martin Nowak
Collaborator

Sounds reasonable.

Martin Nowak
Collaborator

I've rewritten this in a more conservative way.
It now only alters the -g behavior for DWARF.
The old behavior can be enabled with defining
USE_DWARF_D_EXTENSIONS in dwarf.h.
Hopefully it will not rot as the struct code in toctype.c.

It would be great if we'd mangle the types.
Then the typenames could be
_Array_ElementMangle
_AArray_KeyMangle_ValueMangle
_Delegate_TypeFunctionMangle

GDB has a D demangler and can be made to display them accordingly.
I will see how to add this later, there is no D mangler around the backend, is it?

Mathias L. Baumann

Do want!

Vladimir Panteleev

By the way, would it be possible to add a switch to emit DWARF debug info on Windows? Some debuggers/profilers (e.g. Very Sleepy) understand DWARF but not CodeView.

Martin Nowak
Collaborator

Yeah, but AA support won't work.
I think we're better of to add python scripts for them, but they require a specific binary to be associated with. So this will only get usable with a shared phobos2.

Leandro Lucarella
Walter Bright WalterBright merged commit f37b755 into from
Brad Roberts braddr referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
AlexeyProkhin AlexeyProkhin referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 25, 2011
  1. Martin Nowak

    update DWARF to use a struct as array type

    MartinNowak authored
     - added USE_DWARF_D_EXTENSIONS macro to enable/disable
       the extensions
    
    fixup first
  2. Martin Nowak
  3. Martin Nowak
  4. Martin Nowak

    disable DWARF D extensions

    MartinNowak authored
This page is out of date. Refresh to see the latest.
Showing with 173 additions and 0 deletions.
  1. +169 −0 src/backend/dwarf.c
  2. +2 −0  src/backend/dwarf.h
  3. +2 −0  src/backend/dwarf2.h
169 src/backend/dwarf.c
View
@@ -1504,6 +1504,7 @@ unsigned dwarf_typidx(type *t)
DW_AT_byte_size, DW_FORM_data1,
0, 0,
};
+#ifdef USE_DWARF_D_EXTENSIONS
static unsigned char abbrevTypeDArray[] =
{
DW_TAG_darray_type,
@@ -1537,6 +1538,7 @@ unsigned dwarf_typidx(type *t)
DW_AT_type, DW_FORM_ref4, // function type
0, 0,
};
+#endif // USE_DWARF_D_EXTENSIONS
static unsigned char abbrevTypeConst[] =
{
DW_TAG_const_type,
@@ -1622,9 +1624,33 @@ unsigned dwarf_typidx(type *t)
{ p = (tybasic(t->Tty) == TYullong) ? "unsigned long long" : "ucent";
goto Lsigned;
}
+
+#ifndef USE_DWARF_D_EXTENSIONS
+ static unsigned char abbrevTypeStruct[] =
+ {
+ DW_TAG_structure_type,
+ 1, // children
+ DW_AT_sibling, DW_FORM_ref4,
+ DW_AT_name, DW_FORM_string,
+ DW_AT_byte_size, DW_FORM_data1,
+ 0, 0,
+ };
+
+ static unsigned char abbrevTypeMember[] =
+ {
+ DW_TAG_member,
+ 0, // no children
+ DW_AT_name, DW_FORM_string,
+ DW_AT_type, DW_FORM_ref4,
+ DW_AT_data_member_location, DW_FORM_block1,
+ 0, 0,
+ };
+#endif
+
/* It's really TYdarray, and Tnext is the
* element type
*/
+#ifdef USE_DWARF_D_EXTENSIONS
nextidx = dwarf_typidx(t->Tnext);
code = nextidx
? dwarf_abbrev_code(abbrevTypeDArray, sizeof(abbrevTypeDArray))
@@ -1634,6 +1660,56 @@ unsigned dwarf_typidx(type *t)
infobuf->writeByte(tysize(t->Tty)); // DW_AT_byte_size
if (nextidx)
infobuf->write32(nextidx); // DW_AT_type
+#else
+ {
+ unsigned lenidx = I64 ? dwarf_typidx(tsulong) : dwarf_typidx(tsuns);
+
+ {
+ type *tdata = type_alloc(TYnptr);
+ tdata->Tnext = t->Tnext;
+ t->Tnext->Tcount++;
+ tdata->Tcount++;
+ nextidx = dwarf_typidx(tdata);
+ type_free(tdata);
+ }
+
+ code = dwarf_abbrev_code(abbrevTypeStruct, sizeof(abbrevTypeStruct));
+ idx = infobuf->size();
+ infobuf->writeuLEB128(code); // abbreviation code
+ unsigned siblingoffset = infobuf->size();
+ unsigned idxsibling = 0;
+ infobuf->write32(idxsibling); // DW_AT_sibling
+ infobuf->write("_Array_", 7); // DW_AT_name
+ if (tybasic(t->Tnext->Tty))
+ infobuf->writeString(tystring[tybasic(t->Tnext->Tty)]);
+ else
+ infobuf->writeByte(0);
+ infobuf->writeByte(tysize(t->Tty)); // DW_AT_byte_size
+
+ // length
+ code = dwarf_abbrev_code(abbrevTypeMember, sizeof(abbrevTypeMember));
+ infobuf->writeuLEB128(code); // abbreviation code
+ infobuf->writeString("length"); // DW_AT_name
+ infobuf->write32(lenidx); // DW_AT_type
+
+ infobuf->writeByte(2); // DW_AT_data_member_location
+ infobuf->writeByte(DW_OP_plus_uconst);
+ infobuf->writeByte(0);
+
+ // ptr
+ infobuf->writeuLEB128(code); // abbreviation code
+ infobuf->writeString("ptr"); // DW_AT_name
+ infobuf->write32(nextidx); // DW_AT_type
+
+ infobuf->writeByte(2); // DW_AT_data_member_location
+ infobuf->writeByte(DW_OP_plus_uconst);
+ infobuf->writeByte(I64 ? 8 : 4);
+
+ infobuf->writeByte(0); // no more siblings
+ idxsibling = infobuf->size();
+ *(unsigned *)(infobuf->buf + siblingoffset) = idxsibling;
+ }
+#endif
break;
case TYllong:
@@ -1645,6 +1721,7 @@ unsigned dwarf_typidx(type *t)
/* It's really TYdelegate, and Tnext is the
* function type
*/
+#ifdef USE_DWARF_D_EXTENSIONS
{ type *tv = type_fake(TYnptr);
tv->Tcount++;
pvoididx = dwarf_typidx(tv); // void* is the 'this' type
@@ -1657,6 +1734,52 @@ unsigned dwarf_typidx(type *t)
infobuf->writeByte(tysize(t->Tty)); // DW_AT_byte_size
infobuf->write32(pvoididx); // DW_AT_containing_type
infobuf->write32(nextidx); // DW_AT_type
+#else
+ {
+ {
+ type *tp = type_fake(TYnptr);
+ tp->Tcount++;
+ pvoididx = dwarf_typidx(tp); // void*
+
+ tp->Tnext = t->Tnext; // fptr*
+ tp->Tnext->Tcount++;
+ nextidx = dwarf_typidx(tp);
+ type_free(tp);
+ }
+
+ code = dwarf_abbrev_code(abbrevTypeStruct, sizeof(abbrevTypeStruct));
+ idx = infobuf->size();
+ infobuf->writeuLEB128(code); // abbreviation code
+ unsigned siblingoffset = infobuf->size();
+ unsigned idxsibling = 0;
+ infobuf->write32(idxsibling); // DW_AT_sibling
+ infobuf->writeString("_Delegate"); // DW_AT_name
+ infobuf->writeByte(tysize(t->Tty)); // DW_AT_byte_size
+
+ // ctxptr
+ code = dwarf_abbrev_code(abbrevTypeMember, sizeof(abbrevTypeMember));
+ infobuf->writeuLEB128(code); // abbreviation code
+ infobuf->writeString("ctxptr"); // DW_AT_name
+ infobuf->write32(pvoididx); // DW_AT_type
+
+ infobuf->writeByte(2); // DW_AT_data_member_location
+ infobuf->writeByte(DW_OP_plus_uconst);
+ infobuf->writeByte(0);
+
+ // funcptr
+ infobuf->writeuLEB128(code); // abbreviation code
+ infobuf->writeString("funcptr"); // DW_AT_name
+ infobuf->write32(nextidx); // DW_AT_type
+
+ infobuf->writeByte(2); // DW_AT_data_member_location
+ infobuf->writeByte(DW_OP_plus_uconst);
+ infobuf->writeByte(I64 ? 8 : 4);
+
+ infobuf->writeByte(0); // no more siblings
+ idxsibling = infobuf->size();
+ *(unsigned *)(infobuf->buf + siblingoffset) = idxsibling;
+ }
+#endif
break;
case TYnref:
@@ -1668,6 +1791,7 @@ unsigned dwarf_typidx(type *t)
/* It's really TYaarray, and Tnext is the
* element type, Tkey is the key type
*/
+#ifdef USE_DWARF_D_EXTENSIONS
keyidx = dwarf_typidx(t->Tkey);
nextidx = dwarf_typidx(t->Tnext);
code = dwarf_abbrev_code(abbrevTypeAArray, sizeof(abbrevTypeAArray));
@@ -1676,6 +1800,51 @@ unsigned dwarf_typidx(type *t)
infobuf->writeByte(tysize(t->Tty)); // DW_AT_byte_size
infobuf->write32(nextidx); // DW_AT_type
infobuf->write32(keyidx); // DW_AT_containing_type
+#else
+ {
+ {
+ type *tp = type_fake(TYnptr);
+ tp->Tcount++;
+ pvoididx = dwarf_typidx(tp); // void*
+ }
+
+ code = dwarf_abbrev_code(abbrevTypeStruct, sizeof(abbrevTypeStruct));
+ idx = infobuf->size();
+ infobuf->writeuLEB128(code); // abbreviation code
+ unsigned siblingoffset = infobuf->size();
+ unsigned idxsibling = 0;
+ infobuf->write32(idxsibling); // DW_AT_sibling
+ infobuf->write("_AArray_", 8); // DW_AT_name
+ if (tybasic(t->Tkey->Tty))
+ p = tystring[tybasic(t->Tkey->Tty)];
+ else
+ p = "key";
+ infobuf->write(p, strlen(p));
+
+ infobuf->writeByte('_');
+ if (tybasic(t->Tnext->Tty))
+ p = tystring[tybasic(t->Tnext->Tty)];
+ else
+ p = "value";
+ infobuf->writeString(p);
+
+ infobuf->writeByte(tysize(t->Tty)); // DW_AT_byte_size
+
+ // ptr
+ code = dwarf_abbrev_code(abbrevTypeMember, sizeof(abbrevTypeMember));
+ infobuf->writeuLEB128(code); // abbreviation code
+ infobuf->writeString("ptr"); // DW_AT_name
+ infobuf->write32(pvoididx); // DW_AT_type
+
+ infobuf->writeByte(2); // DW_AT_data_member_location
+ infobuf->writeByte(DW_OP_plus_uconst);
+ infobuf->writeByte(0);
+
+ infobuf->writeByte(0); // no more siblings
+ idxsibling = infobuf->size();
+ *(unsigned *)(infobuf->buf + siblingoffset) = idxsibling;
+ }
+#endif
break;
case TYvoid: return 0;
2  src/backend/dwarf.h
View
@@ -4,6 +4,8 @@
/* ==================== Dwarf debug ======================= */
+// #define USE_DWARF_D_EXTENSIONS
+
void dwarf_initfile(const char *filename);
void dwarf_termfile();
void dwarf_initmodule(const char *filename, const char *modulename);
2  src/backend/dwarf2.h
View
@@ -65,9 +65,11 @@ enum
DW_TAG_shared_type = 0x40,
// D programming language extensions
+#ifdef USE_DWARF_D_EXTENSIONS
DW_TAG_darray_type = 0x41,
DW_TAG_aarray_type = 0x42,
DW_TAG_delegate_type = 0x43,
+#endif
DW_TAG_lo_user = 0x4080,
DW_TAG_hi_user = 0xFFFF,
Something went wrong with that request. Please try again.