summaryrefslogtreecommitdiff
path: root/Applications/Debugger
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-12 21:07:52 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-12 21:28:55 +0200
commitfdfda6dec20101013bb33633e657f06ef2a1ea96 (patch)
tree2157f8281cd9bc33a6984455c4831c397d2bd30c /Applications/Debugger
parent15f4043a7a80f52c0fa05c4e69771e758464cd20 (diff)
downloadserenity-fdfda6dec20101013bb33633e657f06ef2a1ea96.zip
AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
Diffstat (limited to 'Applications/Debugger')
-rw-r--r--Applications/Debugger/main.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/Applications/Debugger/main.cpp b/Applications/Debugger/main.cpp
index 31f47046a2..367fe89001 100644
--- a/Applications/Debugger/main.cpp
+++ b/Applications/Debugger/main.cpp
@@ -76,10 +76,10 @@ bool handle_disassemble_command(const String& command, void* first_instruction)
auto parts = command.split(' ');
size_t number_of_instructions_to_disassemble = 5;
if (parts.size() == 2) {
- bool ok;
- number_of_instructions_to_disassemble = parts[1].to_uint(ok);
- if (!ok)
+ auto number = parts[1].to_uint();
+ if (!number.has_value())
return false;
+ number_of_instructions_to_disassemble = number.value();
}
// FIXME: Instead of using a fixed "dump_size",
@@ -126,14 +126,13 @@ bool handle_breakpoint_command(const String& command)
auto source_arguments = argument.split(':');
if (source_arguments.size() != 2)
return false;
- bool ok = false;
- size_t line = source_arguments[1].to_uint(ok);
- if (!ok)
+ auto line = source_arguments[1].to_uint();
+ if (!line.has_value())
return false;
auto file = source_arguments[0];
if (!file.contains("/"))
file = String::format("./%s", file.characters());
- auto result = g_debug_session->debug_info().get_instruction_from_source(file, line);
+ auto result = g_debug_session->debug_info().get_instruction_from_source(file, line.value());
if (!result.has_value()) {
printf("No matching instruction found\n");
return false;