Don't replace '\' with '\\' in before_prompt_hook
authorYao Qi <yao@codesourcery.com>
Thu, 30 Oct 2014 01:42:36 +0000 (09:42 +0800)
committerYao Qi <yao@codesourcery.com>
Thu, 30 Oct 2014 01:42:36 +0000 (09:42 +0800)
In gdb/command/prompt.py:before_prompt_hook, the '\' in the new prompt
is replaced with '\\', shown as below,

>     def before_prompt_hook(self, current):
>         if self.value is not '':
>             newprompt = gdb.prompt.substitute_prompt(self.value)
>             return newprompt.replace('\\', '\\\\')
>         else:
>             return None

I don't see any explanations on this in comments nor email.  As doc
said, "set extended-prompt \w" substitute the current working
directory, but it prints something different from what pwd or
os.getcwdu() prints on mingw32 host.

(gdb) python print os.getcwdu()^M
\\build2-lucid-cs\yqi\yqi\arm-none-eabi

(gdb) pwd^M
Working directory \\build2-lucid-cs\yqi\yqi\arm-none-eabi

(gdb) set extended-prompt \w
\\\\build2-lucid-cs\\yqi\\yqi\\arm-none-eabi

This makes me think whether the substitution in before_prompt_hook is
necessary or not.  This patch is to remove this substitution.

Run gdb.python on x86_64-linux and arm-none-eabi on mingw32 host.  No
regressions.

gdb:

2014-10-30  Yao Qi  <yao@codesourcery.com>

* python/lib/gdb/command/prompt.py (before_prompt_hook): Don't
replace '\\' with '\\\\'.

gdb/ChangeLog
gdb/python/lib/gdb/command/prompt.py

index d4dc470953deb7e04ac1540fd555027a3e41e3be..6d4a9af708d668c9b92fe507494db43487ece803 100644 (file)
@@ -1,3 +1,8 @@
+2014-10-30  Yao Qi  <yao@codesourcery.com>
+
+       * python/lib/gdb/command/prompt.py (before_prompt_hook): Don't
+       replace '\\' with '\\\\'.
+
 2014-10-29  Joel Brobecker  <brobecker@adacore.com>
 
        GDB 7.8.1 released.
index e7dc3daa249cefc457a12e7c8f8acc55369a89e0..5e973e4b6efaaa66f4f30261f611a21771273b45 100644 (file)
@@ -58,8 +58,7 @@ The currently defined substitutions are:
 
     def before_prompt_hook(self, current):
         if self.value is not '':
-            newprompt = gdb.prompt.substitute_prompt(self.value)
-            return newprompt.replace('\\', '\\\\')
+            return gdb.prompt.substitute_prompt(self.value)
         else:
             return None
 
This page took 0.032323 seconds and 4 git commands to generate.