================
@@ -277,6 +286,143 @@ lldb::addr_t ProcessFreeBSDKernel::FindSymbol(const char
*name) {
return sym ? sym->GetLoadAddress(&GetTarget()) : LLDB_INVALID_ADDRESS;
}
+void ProcessFreeBSDKernel::ShowCrashInfo() {
+ Target &target = GetTarget();
+ Debugger &debugger = target.GetDebugger();
+
+ if (!debugger.GetCommandInterpreter().IsInteractive())
+ return;
+
+ Status error;
+
+ // Find msgbufp symbol (pointer to message buffer)
+ lldb::addr_t msgbufp_addr = FindSymbol("msgbufp");
+ if (msgbufp_addr == LLDB_INVALID_ADDRESS)
+ return;
+
+ // Read the pointer value
+ lldb::addr_t msgbufp = ReadPointerFromMemory(msgbufp_addr, error);
+ if (!error.Success() || msgbufp == LLDB_INVALID_ADDRESS)
+ return;
+
+ // Get the type information for struct msgbuf from DWARF
+ TypeQuery query("msgbuf");
+ TypeResults results;
+ target.GetImages().FindTypes(nullptr, query, results);
+
+ uint64_t offset_msg_ptr = 0;
+ uint64_t offset_msg_size = 0;
+ uint64_t offset_msg_wseq = 0;
+ uint64_t offset_msg_rseq = 0;
+
+ if (results.GetTypeMap().GetSize() > 0) {
+ // Found type info - use it to get field offsets
+ CompilerType msgbuf_type =
+ results.GetTypeMap().GetTypeAtIndex(0)->GetForwardCompilerType();
+
+ uint32_t num_fields = msgbuf_type.GetNumFields();
+ for (uint32_t i = 0; i < num_fields; i++) {
+ std::string field_name;
+ uint64_t field_offset = 0;
+ uint32_t field_bitfield_bit_size = 0;
+ bool field_is_bitfield = false;
+
+ msgbuf_type.GetFieldAtIndex(i, field_name, &field_offset,
+ &field_bitfield_bit_size,
&field_is_bitfield);
+
+ if (field_name == "msg_ptr")
+ offset_msg_ptr = field_offset / 8; // Convert bits to bytes
+ else if (field_name == "msg_size")
+ offset_msg_size = field_offset / 8;
+ else if (field_name == "msg_wseq")
+ offset_msg_wseq = field_offset / 8;
+ else if (field_name == "msg_rseq")
+ offset_msg_rseq = field_offset / 8;
+ }
----------------
Michael137 wrote:
This is not resilient to changes in the structure layout. Lets check that the
number of fields is the number you expect (i.e., 5) and if any of the field
names don't appear in the structure you should bail out of this function.
https://github.com/llvm/llvm-project/pull/178027
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits