The Tcl global command has no effect unless executed in the context of a proc body. So the global commands in the following code are useless. Even worse, they would cause unexpected result. When gdb_expect gets something containing "global", it will try to execute hex as a command, which will cause an error. gdb_expect { global hex global nl global bp_addr global gdb_prompt -re "$hex.*${nl}($hex).*$gdb_prompt $" { set bp_addr $expect_out(1,string) pass "get breakpoint address for foo" } -re ".*$gdb_prompt $" { fail "get breakpoint address for foo" return 0; } timeout { fail "get breakpoint address for foo (timeout)" return 0; } } This patch should fix this issue. Is it OK? Thanks, Jie