i am trying to use gdb with alsa-lib in the next code, i use gdb for see a pointer struct, but i find this <incomplete type>
when use gdb
i use for compiler the gcc and i put a flag -lasound
gcc ejemplo.c -lasound -g -o ejemplo
+
#include <alsa/asoundlib.h>
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
//#include"pcm_local.h"
//#include <sound/asound.h>
int main()
{
snd_pcm_t *handle_capture;
snd_pcm_open(&handle_capture,"default", SND_PCM_STREAM_PLAYBACK, SND_PCM_ASYNC);
return 0;
}
i put a break in line 15 (before return 0) and see this
(gdb) break 15
(gdb) p *handle_capture
<incomplete type>
i see pcm.h a declaration in line 327
typedef struct _snd_pcm snd_pcm_t
and search _snd_pcm and i find of declaration in "pcm_local.h"
line 179
struct _snd_pcm {
i add the library but a appear errors or double declaration.
also i see the declarations of libasound.so
nm -D /usr/lib/x86_64-linux-gnu/libasound.so
but i don't find the declaration (_snd_pcm or snd_pcm_t), and see that i don't know it is possible use gdb if in libasond.so don't appear this declaration.
i read in other post that a problem is solve if add #include <sound/asound.h>
but i find same error of double declaration, i think that i solve error of double declaration comment parts in library pcm_local.h of code but i don't know if it is a good solution, any can help me, what do i need to know for use gdb whith alsa?, i searched in google (Googlear) any solution but i don't find any solution.
Your program doesn't include pcm_local.h
. The pointer you're using is intended to be used as an opaque pointer. The include file intended for use by applications has just a forward declaration. Your application is supposed to treat it like a handle, analogous to FILE *
.
You probably don't really want to know what it points to. If you do, you'll have to make sure your alsa library is compiled with debugging information attached (not stripped), and you'll have to step into the alsa library function deep enough until you reach code that does include pcm_local.h
.
Yes, there are ways to include the structure definition and get gdb to dereference the pointer for you. But that way lies madness. Tricking a debugger into doing something is a good way to fake yourself out.
If what you're really interested in is some aspect of the state of the alsa handle, look for functions that report its state.