[Lldb-commits] [PATCH] D129588: [trace] Avoid a crash in the dumper when disassembling fails
Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 12 16:23:30 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdbc0cb019812: [trace] Avoid a crash in the dumper when disassembling fails (authored by Walter Erquinigo <wallace at fb.com>).
Changed prior to commit:
https://reviews.llvm.org/D129588?vs=444063&id=444107#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129588/new/
https://reviews.llvm.org/D129588
Files:
lldb/source/Target/TraceDumper.cpp
Index: lldb/source/Target/TraceDumper.cpp
===================================================================
--- lldb/source/Target/TraceDumper.cpp
+++ lldb/source/Target/TraceDumper.cpp
@@ -145,7 +145,7 @@
m_s << "(error) " << *item.error;
} else {
m_s.Format("{0:x+16}", item.load_address);
- if (item.symbol_info) {
+ if (item.symbol_info && item.symbol_info->instruction) {
m_s << " ";
item.symbol_info->instruction->Dump(
&m_s, /*max_opcode_byte_size=*/0,
@@ -200,6 +200,35 @@
~OutputWriterJSON() { m_j.arrayEnd(); }
+ void DumpEvent(const TraceDumper::TraceItem &item) {
+ m_j.attribute("event", TraceCursor::EventKindToString(*item.event));
+ }
+
+ void DumpInstruction(const TraceDumper::TraceItem &item) {
+ m_j.attribute("loadAddress", formatv("{0:x}", item.load_address));
+ if (item.symbol_info) {
+ m_j.attribute("module", ToOptionalString(GetModuleName(item)));
+ m_j.attribute(
+ "symbol",
+ ToOptionalString(item.symbol_info->sc.GetFunctionName().AsCString()));
+
+ if (item.symbol_info->instruction) {
+ m_j.attribute("mnemonic",
+ ToOptionalString(item.symbol_info->instruction->GetMnemonic(
+ &item.symbol_info->exe_ctx)));
+ }
+
+ if (IsLineEntryValid(item.symbol_info->sc.line_entry)) {
+ m_j.attribute(
+ "source",
+ ToOptionalString(
+ item.symbol_info->sc.line_entry.file.GetPath().c_str()));
+ m_j.attribute("line", item.symbol_info->sc.line_entry.line);
+ m_j.attribute("column", item.symbol_info->sc.line_entry.column);
+ }
+ }
+ }
+
void TraceItem(const TraceDumper::TraceItem &item) override {
m_j.object([&] {
m_j.attribute("id", item.id);
@@ -209,9 +238,7 @@
item.tsc ? Optional<std::string>(std::to_string(*item.tsc)) : None);
if (item.event) {
- m_j.object([&] {
- m_j.attribute("event", TraceCursor::EventKindToString(*item.event));
- });
+ DumpEvent(item);
return;
}
@@ -221,26 +248,7 @@
}
// we know we are seeing an actual instruction
- m_j.attribute("loadAddress", formatv("{0:x}", item.load_address));
- if (item.symbol_info) {
- m_j.attribute("module", ToOptionalString(GetModuleName(item)));
- m_j.attribute("symbol",
- ToOptionalString(
- item.symbol_info->sc.GetFunctionName().AsCString()));
- m_j.attribute(
- "mnemonic",
- ToOptionalString(item.symbol_info->instruction->GetMnemonic(
- &item.symbol_info->exe_ctx)));
-
- if (IsLineEntryValid(item.symbol_info->sc.line_entry)) {
- m_j.attribute(
- "source",
- ToOptionalString(
- item.symbol_info->sc.line_entry.file.GetPath().c_str()));
- m_j.attribute("line", item.symbol_info->sc.line_entry.line);
- m_j.attribute("column", item.symbol_info->sc.line_entry.column);
- }
- }
+ DumpInstruction(item);
});
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129588.444107.patch
Type: text/x-patch
Size: 3166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220712/1aad7d30/attachment.bin>
More information about the lldb-commits
mailing list