2011-07-21 Phil Muldoon <pmuldoon@redhat.com>

Tom Tromey  <tromey@redhat.com>

	* top.c (set_prompt): Rewrite to free previous prompt, free
	asynch_new_prompt and set both on new prompts.
	* event-top.c (display_gdb_prompt): Add prompt substitution
	logic.
	* python/python.c (before_prompt_hook): New function.

2011-07-21  Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.python/python.exp: Add prompt substitution tests.

2011-07-21  Phil Muldoon  <pmuldoon@redhat.com>

	* observer.texi (GDB Observers): Add before_prompt observer.
	* gdb.texinfo (Basic Python): Add documentation for prompt
	substitution.
This commit is contained in:
Phil Muldoon 2011-07-21 11:03:48 +00:00
parent 3779080d04
commit d17b6f8101
10 changed files with 256 additions and 23 deletions

View file

@ -193,3 +193,85 @@ gdb_py_test_silent_cmd "set python print-stack on" \
"Test print-backtrace set setting" 1
gdb_test "show python print-stack" \
"Whether Python stack will be printed on error is on.*" \
# Test prompt substituion
gdb_py_test_multiple "prompt substitution" \
"python" "" \
"someCounter = 0" "" \
"def prompt(current):" "" \
" global someCounter" "" \
" if (current == \"testfake \"):" "" \
" return None" "" \
" someCounter = someCounter + 1" "" \
" return \"py prompt \" + str (someCounter) + \" \"" "" \
"end" ""
gdb_py_test_multiple "prompt substitution readline" \
"python" "" \
"pCounter = 0" "" \
"def program_prompt(current):" "" \
" global pCounter" "" \
" if (current == \">\"):" "" \
" pCounter = pCounter + 1" "" \
" return \"python line \" + str (pCounter) + \": \"" "" \
" return None" "" \
"end" ""
set newprompt "py prompt 1"
set newprompt2 "py prompt 2"
set testfake "testfake"
gdb_test_multiple "python gdb.prompt_hook = prompt" "set the hook" {
-re "\[\r\n\]$newprompt $" {
pass "set hook"
}
}
gdb_test_multiple "set prompt testfake " "set testfake prompt in GDB" {
-re "\[\r\n\]$testfake $" {
pass "set prompt testfake"
}
}
gdb_test_multiple "show prompt" "show testfake prompt" {
-re "Gdb's prompt is \"$testfake \"..* $" {
pass "show prompt shows guarded prompt"
}
}
gdb_test_multiple "set prompt blah " "set blah in GDB" {
-re "\[\r\n\]$newprompt2 $" {
pass "set prompt blah overriden"
}
}
gdb_test_multiple "python gdb.prompt_hook = None" "Delete hook" {
-re "\[\r\n\]$newprompt2 $" {
pass "Delete old hook"
}
}
gdb_test_multiple "set prompt $gdb_prompt " "set default prompt" {
-re "\[\r\n\]$gdb_prompt $" {
pass "set default prompt"
}
}
gdb_test_multiple "python gdb.prompt_hook = program_prompt" "set the hook" {
-re "\[\r\n\]$gdb_prompt $" {
pass "set programming hook"
}
}
gdb_test_multiple "python" "test we ignore substituion for seconday prompts" {
-re "\r\n>$" {
pass "readline secondary are not substituted"
}
}
gdb_test_multiple "end" "end programming" {
-re "\[\r\n\]$gdb_prompt $" {
pass "end programming"
}
}