Subject: bug#21572: 24.5; Gud gdb doesn't load source files with utf-8 chars in the file name

From: Eli Zaretskii <[email-masked]>
Date: Wed, 30 Sep 2015 20:52:24 +0300

> From: Augusto Fraga Giachero <[email-masked]>
> Date: Sun, 27 Sep 2015 12:26:55 -0300
> 
> I'm having problems when trying to debug a program with gdb. The GUD
> doesn't load the source files if they have any utf-8 character in their
> names. I know that gdb replaces utf-8 characters with backslash and
> their corresponding octal value, it seems that GUD isn't parsing these
> octal sequences.

They are just ASCII characters, so GUD had no reason to parse them.

> Here is an part of my gdb-source-file-list:
> 
> (... "/home/augusto/Projetos/Eletr\303\264nica/ARM/IoControl/src/main.c"
> ...)
> 
> The correct path should be:
> /home/augusto/Projetos/Eletrônica/ARM/IoControl/src/main.c
> 
> I think it's not hard to fix it

Actually, it's not very simple.  GDB outputs octal escapes in every
string, not just in file names, so decoding should be done on a very
low level, where we don't yet know what is a file name and what is
some other string (like a value of some string variable).  We can
decode that if we assume that all the strings output by GDB are
encoded the same (in your case, probably UTF-8), and keeping fingers
crossed that the communications channel between GBD and Emacs never
breaks the 3-digit sequence due to buffering issues.

I have a prototype fix along the above-mentioned lines which I will
commit soon, unless someone has a better idea.  You could then patch
your gdb-mi.el and use it with those source files.

Alternatively, you can invoke GDB via "M-x gud-gdb RET", which doesn't
have this problem in the first place.

Thanks.