+ def lognames(self):
+ return [logfile.name for logfile in self.logfiles]
+
+ def select_child(self, child):
+ self.active_child = child
+
+ def select_hart(self, hart):
+ h = self.harts[hart.id]
+ self.select_child(h['child'])
+ if not h['solo']:
+ output = self.command("thread %s" % h['thread'].id, ops=5)
+ assert "Unknown" not in output
+
+ def push_state(self):
+ self.stack.append({
+ 'active_child': self.active_child
+ })
+
+ def pop_state(self):
+ state = self.stack.pop()
+ self.active_child = state['active_child']
+
+ def wait(self):
+ """Wait for prompt."""
+ self.active_child.expect(r"\(gdb\)")
+
+ def command(self, command, ops=1):
+ """ops is the estimated number of operations gdb will have to perform
+ to perform this command. It is used to compute a timeout based on
+ self.timeout."""
+ timeout = ops * self.timeout
+ self.active_child.sendline(command)
+ self.active_child.expect("\n", timeout=timeout)
+ self.active_child.expect(r"\(gdb\)", timeout=timeout)
+ return self.active_child.before.strip()
+
+ def global_command(self, command):
+ """Execute this command on every gdb that we control."""
+ with PrivateState(self):
+ for child in self.children:
+ self.select_child(child)
+ self.command(command)
+
+ def c(self, wait=True, async=False):
+ """
+ Dumb c command.
+ In RTOS mode, gdb will resume all harts.
+ In multi-gdb mode, this command will just go to the current gdb, so
+ will only resume one hart.
+ """