Segmentation fault hell in D

bioinfornatics bioinfornatics at fedoraproject.org
Sun Jun 10 04:07:14 PDT 2012


Le vendredi 08 juin 2012 à 19:30 +0200, Jarl =?UTF-8?B?QW5kcsOpIg==?= a
écrit :
> Evry single time I encounter them I yawn. It means using the next 
> frickin hour to comment away code, add more log statements and 
> try to eleminate whats creating the hell of bugz, segmantation 
> fault. Why can't the compiler tell me anything else than the fact 
> that i have referenced data that does not exist? Thanks I knew 
> that. Now, please tell me where the error occured.... Jeezes.

Hi, te best way that is to use ldc or gdc with -g flag
i use ldc2 me from fedora repo
$ sudo yum install ldc2* // install D compiler, D standard library,
headers ...
$ sudo yum install dustmite // this tool are really help full to get a
minimall test cease
$ ulimit -c unlimited // able to generate core dump
$ ldc2 myProgram.d
$ ./dustmite_snippet.sh myProgram
---------------------
$ cat ./dustmite_snippet.sh
#!/bin/sh
BINARY=$1 #the binary to test
SEGFUNC="_aaDelX" #the function where the segfault occurs (as in the gdb
backtrace!)
ldc2 $1.d -of$BINARY 2>/dev/null #Your compile command

echo $(sh -c "./$BINARY" 2>&1) | grep -q "Erreur de segmentation" #Make
sure there was a segfault
if [ $? -eq 0 ]
then
    gdb --batch -ex 'backtrace' $BINARY core 2>&1 | grep -q "#0 .* in
$SEGFUNC"
    if [ $? -eq 0 ]
    then
        return 0
    else
        return 1
    fi
else
    return 1
fi





More information about the Digitalmars-d-learn mailing list