[Issue 7454] Add file and line numbers to Linux stack traces using addr2line

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 24 19:00:17 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7454


Artem Borisovskiy <kolos80 at bk.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kolos80 at bk.ru


--- Comment #1 from Artem Borisovskiy <kolos80 at bk.ru> 2012-08-24 18:59:56 PDT ---
Jonathan, I wrote a script that does the job, you can use it until the bug gets
fixed. Just feed it with stack trace and you'll get not only file names and
line numbers (in red color), but also the corresponding lines.

---------
#!/bin/sh

if [[ "$1" == "" || "$2" != "" ]]; then
    echo "usage: $0 <executable>"
    exit
fi

grep -Po "0x[\d\w]+" | addr2line -e "$1" | grep -v "^??" | sed -r
's/(.*):([0-9]*)/printf "\\033[0;31m\0:\\033[0m\n    " \&\& sed -n \2p \1 | sed
"s\/^ *\/\/"/' | sh
---------

Note: lines from stack trace without corresponding debug info are thrown away.
In my case for stack trace

./micron() [0x4b4216]  
./micron() [0x427941]
./micron() [0x417ffc]
./micron() [0x417f45]
./micron() [0x41899e]
./micron() [0x483931]
./micron() [0x48c282]
./micron() [0x4838b6]
./micron() [0x419320]
./micron() [0x4278e5]
./micron() [0x4d2760]
./micron() [0x4d2335]
./micron() [0x4b8d37]
./micron() [0x4b4b21]
./micron() [0x4b4472]
./micron() [0x4b43fd]

it gives the following output:

/home/burjui/devel/micron-d/code.d:38:
    assert(cell);
/home/burjui/devel/micron-d/code.d:27:
    this(in this)
/home/burjui/devel/micron-d/code.d:169:
    e._value = new Value(*_value);
/home/burjui/devel/micron-d/types.d:349:
    this.return_type = return_type.unlessNull(return_type.clone);
/home/burjui/devel/micron-d/utils.d:118:
    return obj is null ? cast(U)null : ret();
/home/burjui/devel/micron-d/types.d:349:
    this.return_type = return_type.unlessNull(return_type.clone);
/home/burjui/devel/micron-d/code.d:485:
    auto print_type = new FnType((new Void).toExpr, [ FnArg((new
Number(1)).toExpr, "x") ], [], true);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list