# How to get debugging symbols (e.g., DWARF)

**URL:** <https://discourse.haskell.org/t/how-to-get-debugging-symbols-e-g-dwarf/5792>\
**Category:** Learn\
**Created:** [February 11, 2023, 4:48pm UTC](https://discourse.haskell.org/t/how-to-get-debugging-symbols-e-g-dwarf/5792 "2023-02-11T16:48:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tolearn](https://avatars.discourse-cdn.com/v4/letter/t/c77e96/32.png) [@tolearn](https://discourse.haskell.org/u/tolearn)\
**Post date:** [February 11, 2023, 4:48pm UTC](https://discourse.haskell.org/t/how-to-get-debugging-symbols-e-g-dwarf/5792/1 "2023-02-11T16:48:54Z")

</div>

Hi all, I have a question about DWARF of GHC debugging.

Given simple C code, a command `gcc -g example.c -o example` outputs `example` with built DWARF.

```haskell
#include <stdio.h>

int main()
{
    int x = 42;
    printf("The answer is %d\n", x);
    return 0;
}

```

Now I run `dwarfdump example` shows useful DWARF values like follows:

```haskell
< 2><0x0000034b> DW_TAG_variable
                        DW_AT_name x
                        DW_AT_decl_file 0x00000001 ~/example.c
                        DW_AT_decl_line 0x00000005
                        DW_AT_decl_column 0x00000009
                        DW_AT_type <0x00000063>
                        DW_AT_location len 0x0002: 916c: DW_OP_fbreg -20

```

The output description says a variable `x` is declared at line number `5`.

When the similar haskell code comes to compile with `-g` flag (i.e., `ghc -g Main.hs -o Main`):

```haskell
main :: IO ()
main = do
  let x12345 = 1
      x6789 = 2
  putStrLn $ show (x12345 + x6789)

```

The output of `dwarfdump` does not show similar information as shown in the C example. I guess the representation seems different and I have no idea how to find the same information from.

Any comment on how can I find debugging symbols?

Thank you

---

<div class="post-metadata">

**Author:** ![TerrorJack](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/terrorjack/32/5155_2.png) [@TerrorJack](https://discourse.haskell.org/u/TerrorJack)\
**Post date:** [February 11, 2023, 5:53pm UTC](https://discourse.haskell.org/t/how-to-get-debugging-symbols-e-g-dwarf/5792/2 "2023-02-11T17:53:13Z")

</div>

You should be using one of the `-dwarf` flavours of GHC bindists: [Index of /ghc/9.4.4/](https://downloads.haskell.org/ghc/9.4.4/)

---

<div class="post-metadata">

**Author:** ![tolearn](https://avatars.discourse-cdn.com/v4/letter/t/c77e96/32.png) [@tolearn](https://discourse.haskell.org/u/tolearn)\
**Post date:** [February 11, 2023, 7:04pm UTC](https://discourse.haskell.org/t/how-to-get-debugging-symbols-e-g-dwarf/5792/3 "2023-02-11T19:04:10Z")

</div>

Thank you. I’ll give it a try. If it’s within the scope of this question, has the official GHC recently considered adopting DWARF?
