mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
idf_monitor: Aggressively clean up any interactive gdb session
At least on Linux, this can get stuck sometimes and cause terminal weirdness.
This commit is contained in:
parent
8ef7434d55
commit
19d3d25ec2
@ -443,13 +443,25 @@ class Monitor(object):
|
|||||||
with self: # disable console control
|
with self: # disable console control
|
||||||
sys.stderr.write(ANSI_NORMAL)
|
sys.stderr.write(ANSI_NORMAL)
|
||||||
try:
|
try:
|
||||||
subprocess.call(["%sgdb" % self.toolchain_prefix,
|
process = subprocess.Popen(["%sgdb" % self.toolchain_prefix,
|
||||||
"-ex", "set serial baud %d" % self.serial.baudrate,
|
"-ex", "set serial baud %d" % self.serial.baudrate,
|
||||||
"-ex", "target remote %s" % self.serial.port,
|
"-ex", "target remote %s" % self.serial.port,
|
||||||
"-ex", "interrupt", # monitor has already parsed the first 'reason' command, need a second
|
"-ex", "interrupt", # monitor has already parsed the first 'reason' command, need a second
|
||||||
self.elf_file], cwd=".")
|
self.elf_file], cwd=".")
|
||||||
|
process.wait()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass # happens on Windows, maybe other OSes
|
pass # happens on Windows, maybe other OSes
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
# on Linux, maybe other OSes, gdb sometimes seems to be alive even after wait() returns...
|
||||||
|
process.terminate()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
# also on Linux, maybe other OSes, gdb sometimes exits uncleanly and breaks the tty mode
|
||||||
|
subprocess.call(["stty", "sane"])
|
||||||
|
except:
|
||||||
|
pass # don't care if there's no stty, we tried...
|
||||||
self.prompt_next_action("gdb exited")
|
self.prompt_next_action("gdb exited")
|
||||||
|
|
||||||
def output_enable(self, enable):
|
def output_enable(self, enable):
|
||||||
|
Loading…
Reference in New Issue
Block a user