From b4d52467341a77e54f089f7e010da2a9643b55a2 Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Fri, 11 Jun 2021 16:11:43 +0200
Subject: [PATCH] Improve argument handling in hammer-parse-step

---
 gdb-port/utility-commands.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb-port/utility-commands.py b/gdb-port/utility-commands.py
index f446ec8..df25c10 100644
--- a/gdb-port/utility-commands.py
+++ b/gdb-port/utility-commands.py
@@ -17,7 +17,17 @@ class HammerParseStep(gdb.Command):
 
 	def invoke(self, arg, from_tty):
 		args = gdb.string_to_argv(arg)
-		steps = int(args[0])
+		if len(args) > 0:
+			try:
+				steps = int(args[0])
+				if steps < 1:
+					raise ValueError
+			except ValueError:
+				print("Arugment needs to be a positive integer")
+				return
+		else:
+			steps = 1
+
 		gdb.set_convenience_variable("hammer_step_counter", int(steps))
 		# Counting the stops is the responsibility of HDoParseBreakpoint
 		# On each breakpoint hit, something like this is executed in HDoParseBreakpoint.stop():
-- 
GitLab