aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectPlatform.cpp
diff options
context:
space:
mode:
authorMichał Górny <mgorny@moritz.systems>2021-08-06 21:56:15 +0200
committerMichał Górny <mgorny@moritz.systems>2021-09-08 10:58:12 +0200
commit39a2449ea1333886a9c9104b5afb4ff9c4932403 (patch)
treec5fbd08c2fecf847d633bfa834db9f851b4e1fbe /lldb/source/Commands/CommandObjectPlatform.cpp
parentb07803ee2a97fdcf4ed6494d8d6593bf985a5150 (diff)
downloadllvm-39a2449ea1333886a9c9104b5afb4ff9c4932403.zip
llvm-39a2449ea1333886a9c9104b5afb4ff9c4932403.tar.gz
llvm-39a2449ea1333886a9c9104b5afb4ff9c4932403.tar.bz2
[lldb] [Commands] Fix reporting errors in 'platform file read/write'
Fix 'platform file read' and 'platform file write' commands to correctly detect erraneous return and report it as such. Currently, errors were implicitly printed as a return value of -1, and the commands were assumed to be successful. Differential Revision: https://reviews.llvm.org/D107665
Diffstat (limited to 'lldb/source/Commands/CommandObjectPlatform.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 68e1fa6..8dd0512 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -589,11 +589,15 @@ public:
}
std::string buffer(m_options.m_count, 0);
Status error;
- uint32_t retcode = platform_sp->ReadFile(
+ uint64_t retcode = platform_sp->ReadFile(
fd, m_options.m_offset, &buffer[0], m_options.m_count, error);
- result.AppendMessageWithFormat("Return = %d\n", retcode);
- result.AppendMessageWithFormat("Data = \"%s\"\n", buffer.c_str());
- result.SetStatus(eReturnStatusSuccessFinishResult);
+ if (retcode != UINT64_MAX) {
+ result.AppendMessageWithFormat("Return = %" PRIu64 "\n", retcode);
+ result.AppendMessageWithFormat("Data = \"%s\"\n", buffer.c_str());
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ } else {
+ result.AppendError(error.AsCString());
+ }
} else {
result.AppendError("no platform currently selected\n");
}
@@ -678,11 +682,15 @@ public:
cmd_line);
return result.Succeeded();
}
- uint32_t retcode =
+ uint64_t retcode =
platform_sp->WriteFile(fd, m_options.m_offset, &m_options.m_data[0],
m_options.m_data.size(), error);
- result.AppendMessageWithFormat("Return = %d\n", retcode);
- result.SetStatus(eReturnStatusSuccessFinishResult);
+ if (retcode != UINT64_MAX) {
+ result.AppendMessageWithFormat("Return = %" PRIu64 "\n", retcode);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ } else {
+ result.AppendError(error.AsCString());
+ }
} else {
result.AppendError("no platform currently selected\n");
}