# dmd.tocvdebug

Generate debug info in the CV4 debug format.

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: tocvdebug.d

Documentation: https://dlang.org/phobos/dmd_tocvdebug.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/tocvdebug.d

- `visibilityToCVAttr`

  #### Declaration

  `pure nothrow @nogc @safe uint `visibilityToCVAttr`(Visibility.Kind `vis`);`

  CV4 pg. 25 Convert D visibility attribute to cv attribute.

- `cv_align`

  #### Declaration

  `uint `cv_align`(ubyte* `p`, uint `n`);`

  Align and pad.

  #### Return Value

  aligned count

- `cv_udt`

  #### Declaration

  `void `cv_udt`(const char* `id`, uint `typidx`);`

  write a UDT record to the object file

  #### Parameters

  `char* `id`` | name of user defined type
  `uint `typidx`` | type index

- `toDebug`

  #### Declaration

  `void `toDebug`(EnumDeclaration `ed`);`

  Emit symbolic debug info in CV format.

- `CvFieldList`

  #### Declaration

  `struct `CvFieldList`;`

  Helper struct for field list records LF_FIELDLIST/LF_FIELDLIST_V2

  #### Discussion

  if the size exceeds the maximum length of a record, the last entry is an LF_INDEX entry with the type index pointing to the next field list record
  Processing is done in two phases:
  Phase 1: computing the size of the field list and distributing it over multiple records

  - construct `CvFieldList` with some precalculated field count/length
  - for each field, call count(length of field)
  Phase 2: write the actual data
  - call alloc() to allocate debtyp's
  - for each field,
    - call writePtr() to get a pointer into the current debtyp
    - fill memory with field data
    - call written(length of field)
  - call debtyp() to create type records and return the index of the first one
- `cvMember`

  #### Declaration

  `int `cvMember`(Dsymbol `s`, ubyte* `p`);`

  Insert CV info into *`p`.

  #### Return Value

  number of bytes written, or that would be written if `p`==`null`