]> granicus.if.org Git - esp-idf/commitdiff
tools: Print useful error message from idf_monitor when toolchain isn't available
authorRoland Dobai <dobai.roland@gmail.com>
Sat, 1 Dec 2018 15:16:49 +0000 (16:16 +0100)
committerRoland Dobai <dobai.roland@gmail.com>
Wed, 12 Dec 2018 07:22:45 +0000 (08:22 +0100)
tools/idf_monitor.py

index 6b1706c305e41cbb5a98514407a3be11fe0902d7..8ff925add463999eac4752d88a5bcc3be44757bf 100755 (executable)
@@ -565,12 +565,14 @@ class Monitor(object):
                 self.output_enable(True)
 
     def lookup_pc_address(self, pc_addr):
-        translation = subprocess.check_output(
-            ["%saddr2line" % self.toolchain_prefix,
-             "-pfiaC", "-e", self.elf_file, pc_addr],
-            cwd=".")
-        if b"?? ??:0" not in translation:
-            yellow_print(translation.decode())
+        cmd = ["%saddr2line" % self.toolchain_prefix,
+               "-pfiaC", "-e", self.elf_file, pc_addr]
+        try:
+            translation = subprocess.check_output(cmd, cwd=".")
+            if b"?? ??:0" not in translation:
+                yellow_print(translation.decode())
+        except OSError as e:
+            red_print("%s: %s" % (" ".join(cmd), e))
 
     def check_gdbstub_trigger(self, line):
         line = self._gdb_buffer + line
@@ -591,12 +593,15 @@ class Monitor(object):
         with self:  # disable console control
             sys.stderr.write(ANSI_NORMAL)
             try:
-                process = subprocess.Popen(["%sgdb" % self.toolchain_prefix,
-                                            "-ex", "set serial baud %d" % self.serial.baudrate,
-                                            "-ex", "target remote %s" % self.serial.port,
-                                            "-ex", "interrupt",  # monitor has already parsed the first 'reason' command, need a second
-                                            self.elf_file], cwd=".")
+                cmd = ["%sgdb" % self.toolchain_prefix,
+                       "-ex", "set serial baud %d" % self.serial.baudrate,
+                       "-ex", "target remote %s" % self.serial.port,
+                       "-ex", "interrupt",  # monitor has already parsed the first 'reason' command, need a second
+                       self.elf_file]
+                process = subprocess.Popen(cmd, cwd=".")
                 process.wait()
+            except OSError as e:
+                red_print("%s: %s" % (" ".join(cmd), e))
             except KeyboardInterrupt:
                 pass  # happens on Windows, maybe other OSes
             finally: