Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a double variable in gdb with German locale?

Tags:

c++

gdb

I am debugging my c++ program with gdb. I am having difficulties to set a simple double variable because of the German locale.

gdb won't accept values with decimal point. Typed with German decimal point (comma), gdb ignores everything after the comma.

(gdb) p this->foodSupply
$1 = 1
(gdb) set this->foodSupply = 4.3
Ungültige Nummer »4.3«.
(gdb) p this->foodSupply
$1 = 1

(gdb) set this->foodSupply = 4,3
(gdb) p this->foodSupply 
$3 = 4

I figured I can avoid the problem by running gdb with LC_ALL=EN gdb .... But since it's not as easy when working out of my IDE, I want to know if there is another way.

How can a German user type a decimal point in gdb?

like image 482
theHacker Avatar asked Oct 31 '22 12:10

theHacker


1 Answers

Have a look at this bug:
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1341125
There it is maybe explained, why it does not work like you want it to.

You can try a workaround like

(gdb) set this->foodSupply = (double) 43/10  

if your numbers are as simple as 4.3.

like image 113
dontsoft Avatar answered Nov 02 '22 22:11

dontsoft