Source code not showing

1,196 views
Skip to first unread message

José Caballero

unread,
Feb 17, 2015, 7:39:07 AM2/17/15
to cgdb-...@googlegroups.com
I started debugging my program at cgdb and it doesn't show the source code. I'm currently using Ubuntu 14.10 and cgdb 0.6.7. I installed it via apt-get and didn't work.

I also tried installing it from source code, version 0.6.8, but it also didn't show the code. I attach a image while debugging now with the apt-get version:



What is it happening and how can I fix it? I will appreciate the help.

José Caballero

unread,
Feb 17, 2015, 7:41:18 AM2/17/15
to cgdb-...@googlegroups.com
PS: I tried using gdb -tui and it worked fine, but I want to use cgdb.

Bob Rossi

unread,
Feb 17, 2015, 8:49:14 AM2/17/15
to cgdb-...@googlegroups.com
On Tue, Feb 17, 2015 at 04:39:07AM -0800, José Caballero wrote:
> I started debugging my program at cgdb and it doesn't show the source code.
> I'm currently using Ubuntu 14.10 and cgdb 0.6.7. I installed it via apt-get
> and didn't work.
>
> I also tried installing it from source code, version 0.6.8, but it also
> didn't show the code. I attach a image while debugging now with the apt-get
> version:

Use version .6.8, version .6.7 had a nasty hang in it on program close.

As far as the source not showing, I don't recall seeing an issue like
this in a very long time. Typically it means that you have no debugging
information.

After you run your program through cgdb and see no source files, please
attach the contents of,
$HOME/.tgdb/a2_tgdb_debug.txt
$HOME/.tgdb/tgdb_log.txt
so that I can perhaps investigate why your source files can not be
opened.

Thanks,
Bob Rossi
Message has been deleted
Message has been deleted

José Caballero

unread,
Feb 17, 2015, 10:38:55 AM2/17/15
to cgdb-...@googlegroups.com
Here I attach the log files with the 0.6.8 version. Still no source code.
a2_tgdb_debug.txt

José Caballero

unread,
Feb 17, 2015, 11:27:37 AM2/17/15
to cgdb-...@googlegroups.com
I also add that I have compiled the programs with debug info and different programs (snort and the simplest main program)


El martes, 17 de febrero de 2015, 14:49:14 (UTC+1), Bob Rossi escribió:

Bob Rossi

unread,
Feb 17, 2015, 12:15:24 PM2/17/15
to cgdb-...@googlegroups.com
On Tue, Feb 17, 2015 at 07:33:50AM -0800, José Caballero wrote:
> Here I attach the log files after debugging a simple file:
> int main(){
> return 0;
> }
> I'm doing: cgdb ./a
> Still no source code.

Hi,

I see the problem now. Thanks.

In lib/tgdb/annotate-two/commands.c CGDB parses the output of gdb's
server info source command. This is done in,
commands.c:commands_process_info_source
Unfortunately, it looks for the strings
"Located in "
"Current source file is "
when searching for the absolute path.

In your situation, GDB is configured to output in a language besides
English. I suppose this is a bug in CGDB. I don't have any immediate
ideas on how to improve this. The real solution is to no longer use
annotations and to switch to GDB/MI, but this won't be done for some
time.

If you try switching your configuration so that GDB prints in English,
cgdb might immediately start working. Otherwise, let me think of how to
handle this. Any ideas?

Thanks,
Bob Rossi

> ><server list
> >(\r)(\n)
> (\032)(\032)post-prompt(\r)(\n)
> 1 int main(){(\r)(\n)
> 2 return 0;(\r)(\n)
> 3 }(\r)(\n)
> (\r)(\n)
> (\032)(\032)pre-prompt(\r)(\n)
> (gdb) (\r)(\n)
> (\032)(\032)prompt(\r)(\n)
> <server info line
>
> ><server info line
> >(\r)(\n)
> (\032)(\032)post-prompt(\r)(\n)
> Line 3 of "a.c" starts at address 0x4004ff <main+9> and ends at 0x400501.(\r)(\n)
> (\r)(\n)
> (\032)(\032)source /home/user/temp/a.c:3:23:beg:0x4004ff(\r)(\n)
> (\r)(\n)
> (\032)(\032)pre-prompt(\r)(\n)
> (gdb) (\r)(\n)
> (\032)(\032)prompt(\r)(\n)
> <server info source
>
> ><server info source
> >(\r)(\n)
> (\032)(\032)post-prompt(\r)(\n)
> El archivo fuente actual es a.c(\r)(\n)
> Directorio de compilación es /home/user/temp(\r)(\n)
> Situado en /home/user/temp/a.c(\r)(\n)
> Contiene 3 líneas.(\r)(\n)
> El lenguaje fuente es c(\r)(\n)
> Compilado con formato de depuración DWARF 2.(\r)(\n)
> Does not include preprocessor macro info.(\r)(\n)

José Caballero

unread,
Feb 18, 2015, 1:16:04 PM2/18/15
to cgdb-...@googlegroups.com
Yes! That was the problem. I fixed it running the debugger like this:

LANG=C cgdb --args ./a.out

it also works with:

LANG=EN_us cgdb --args ./a.out

Thanks for your help and I'll create an alias or something similar in order to not write LANG=C everytime I run the debugger.

José Antonio Caballero
Reply all
Reply to author
Forward
0 new messages