diff --git a/tools/lldb/netinet.lua b/tools/lldb/netinet.lua --- a/tools/lldb/netinet.lua +++ b/tools/lldb/netinet.lua @@ -1,37 +1,11 @@ -- --- SPDX-License-Identifier: BSD-2-Clause --- -- Copyright (c) 2024 Tom Jones --- All rights reserved. --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions --- are met: --- 1. Redistributions of source code must retain the above copyright --- notice, this list of conditions and the following disclaimer. --- 2. Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. -- --- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND --- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE --- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE --- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE --- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS --- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT --- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY --- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF --- SUCH DAMAGE. +-- SPDX-License-Identifier: BSD-2-Clause -- local netinet = {} --- Module exports --- Commonly appearing constants --- - -- -- Accessing vnet members takes the form: -- (struct inpcbinfo*)((((struct vnet *) vnet0 )->vnet_data_base) + @@ -43,17 +17,17 @@ -- and an output type, i.e. struct pcbinfo * -- function netinet.vnet_get_member(self, vnet, value) - db = vnet:GetChildMemberWithName("vnet_data_base") - v = lldb.target:FindFirstGlobalVariable(value) + local db = vnet:GetChildMemberWithName("vnet_data_base") + local v = lldb.target:FindFirstGlobalVariable(value) :AddressOf() return db:GetValueAsUnsigned() + v:GetValueAsUnsigned() end function netinet.vnet_get_member_and_cast(self, vnet, value, outtype) - db = vnet:GetChildMemberWithName("vnet_data_base") - mb = lldb.target:FindFirstGlobalVariable(value) + local db = vnet:GetChildMemberWithName("vnet_data_base") + local mb = lldb.target:FindFirstGlobalVariable(value) :AddressOf() - addr = db:GetValueAsUnsigned() + mb:GetValueAsUnsigned() + local addr = db:GetValueAsUnsigned() + mb:GetValueAsUnsigned() return lldb.frame:EvaluateExpression("(" .. outtype .. ") " .. addr) end @@ -63,15 +37,14 @@ -- vnet_entry_tcbinfo then get it from the current vnet. function netinet.vnet_get_V_value(self, value, vnet) -- if value starts with V_ it is virtualised - if value:sub(1, 2, "V_") == "V_" + local basevar = value:match("V_(.+)") + if not basevar then - value = value:sub(3, -1, "V_") - else print("vnet_get_V_value: Requires a value name starting with V_, given: " .. value) return nil end - vimage = lldb.target: + local vimage = lldb.target: FindFirstGlobalVariable("sysctl___kern_features_vimage") ~= nil if not vimage