|
From: Misarenkov T. <rg...@in...> - 2008-06-22 11:02:20
|
May be I'm stupid enough, but... I cannot attach debugger to a program. Why?
[rgo ~]$ valgrind --version
valgrind-3.2.3
[rgo ~]$ uname -a
Linux rgo 2.6.24.4-rgo #1 SMP Thu May 8 23:00:59 MSD 2008 x86_64 AMD Athlon(tm) 64 Processor 3500+ AuthenticAMD GNU/Linux
[rgo ~]$ cat >tmp.c <<EOF
#include <stdio.h>
int main ()
{
char tmp;
if (tmp) {
printf ("Ha-ha!\n");
}
return 0;
}
EOF
[rgo ~]$ gcc -ggdb3 -Wall -o tmp tmp.c
[rgo ~]$ valgrind --db-attach=yes ./tmp
==26039== Memcheck, a memory error detector.
==26039== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==26039== Using LibVEX rev 1732, a library for dynamic binary translation.
==26039== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==26039== Using valgrind-3.2.3, a dynamic binary instrumentation framework.
==26039== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==26039== For more details, rerun with: -v
==26039==
==26039== Conditional jump or move depends on uninitialised value(s)
==26039== at 0x4004F4: main (tmp.c:8)
==26039==
==26039== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- y
starting debugger
==26039==
==26039== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 1)
==26039== malloc/free: in use at exit: 0 bytes in 0 blocks.
==26039== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==26039== For counts of detected errors, rerun with: -v
==26039== All heap blocks were freed -- no leaks are possible.
[rgo ~]$
Valgrind prints `starting debugger', but debugger does not run. I tried option
--db-command='/bin/echo must be run "gdb %f %p"', but this changes nothing.
Regards,
Timofey
|
|
From: Robert C. <r.c...@gs...> - 2008-06-23 06:26:59
|
Misarenkov Timofey wrote:
> May be I'm stupid enough, but... I cannot attach debugger to a program. Why?
>
> [rgo ~]$ valgrind --version
> valgrind-3.2.3
> [rgo ~]$ uname -a
> Linux rgo 2.6.24.4-rgo #1 SMP Thu May 8 23:00:59 MSD 2008 x86_64 AMD Athlon(tm) 64 Processor 3500+ AuthenticAMD GNU/Linux
> [rgo ~]$ cat >tmp.c <<EOF
> #include <stdio.h>
>
> int main ()
> {
> char tmp;
> if (tmp) {
> printf ("Ha-ha!\n");
> }
> return 0;
> }
> EOF
> [rgo ~]$ gcc -ggdb3 -Wall -o tmp tmp.c
> [rgo ~]$ valgrind --db-attach=yes ./tmp
> ==26039== Memcheck, a memory error detector.
> ==26039== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
> ==26039== Using LibVEX rev 1732, a library for dynamic binary translation.
> ==26039== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
> ==26039== Using valgrind-3.2.3, a dynamic binary instrumentation framework.
> ==26039== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
> ==26039== For more details, rerun with: -v
> ==26039==
> ==26039== Conditional jump or move depends on uninitialised value(s)
> ==26039== at 0x4004F4: main (tmp.c:8)
> ==26039==
> ==26039== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- y
> starting debugger
> ==26039==
> ==26039== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 1)
> ==26039== malloc/free: in use at exit: 0 bytes in 0 blocks.
> ==26039== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
> ==26039== For counts of detected errors, rerun with: -v
> ==26039== All heap blocks were freed -- no leaks are possible.
> [rgo ~]$
>
> Valgrind prints `starting debugger', but debugger does not run. I tried option
> --db-command='/bin/echo must be run "gdb %f %p"', but this changes nothing.
>
I am by no means an expert, but I put the text below before my normal
command line and it works for me.
valgrind --leak-check=yes --db-attach=yes --db-command="gdb %f %p"
Hope that helps,
Rob.
|
|
From: Bart V. A. <bar...@gm...> - 2008-06-23 06:53:14
|
On Sun, Jun 22, 2008 at 1:02 PM, Misarenkov Timofey <rg...@in...> wrote: > May be I'm stupid enough, but... I cannot attach debugger to a program. Why? > [rgo ~]$ valgrind --db-attach=yes ./tmp The above command should work -- it works at least with the source code on the Valgrind trunk. Did you perform the above test with the Valgrind binary included with your Linux distribution ? In that case you can try to file a bug report in the bug tracking system of your distribution. You can also try to download the Valgrind 3.2.3 or 3.3.1 source code from the Valgrind website and compile and install it yourself. Bart. |