2 """ Please make sure you read the README COMPLETELY BEFORE reading anything below.
3 It is very critical that you read coding guidelines in Section E in README file.
12 from netdefines
import *
13 from routedefines
import *
15 def GetIfFlagsAsString(if_flags
):
16 """ Return a formatted string description of the interface flags
19 flags
= (unsigned
)(if_flags
& 0xffff)
24 out_string
+= if_flags_strings
[i
] + ","
27 return rstrip(out_string
, ",")
30 def ShowIfConfiguration(ifnet
):
31 """ Display ifconfig-like output for the ifnet
33 iface
= Cast(ifnet
, 'ifnet *')
35 format_string
= "{0: <s}: flags={1: <x} <{2: <s}> index {3: <d} mtu {4: <d}"
37 out_string
+= format_string
.format(iface
.if_xname
, (iface
.if_flags
& 0xffff), GetIfFlagsAsString(iface
.if_flags
), iface
.if_index
, iface
.if_data
.ifi_mtu
)
38 out_string
+= "\n\t(struct ifnet *)" + hex(ifnet
)
41 def GetIfConfiguration(ifname
):
42 """ Return ifnet structure corresponding to the ifname passed in
45 ifnets
= kern
.globals.ifnet_head
46 for ifnet
in IterateTAILQ_HEAD(ifnets
, "if_link") :
47 if str(ifnet
.if_xname
) == ifname
:
52 @lldb_command('ifconfig')
53 def ShowIfconfig(cmd_args
=None) :
54 """ Display ifconfig-like output, and print the (struct ifnet *) pointers for further inspection
56 if cmd_args
!= None and len(cmd_args
) > 0:
61 ifnets
= kern
.globals.ifnet_head
62 for ifnet
in IterateTAILQ_HEAD(ifnets
, "if_link"):
63 ShowIfConfiguration(ifnet
)
65 print GetIfaddrs(ifnet
)
68 def GetAddressAsStringColonHex(addr
, count
):
71 addr_format_string
= "{0:02x}"
74 out_string
+= addr_format_string
.format(addr
[i
])[-2:]
76 out_string
+= ":" + addr_format_string
.format(addr
[i
])[-2:]
80 def GetSocketAddrAsStringUnspec(sockaddr
):
82 out_string
+= GetAddressAsStringColonHex(sockaddr
.sa_data
, sockaddr
.sa_len
- 2)
85 def GetSocketAddrAsStringUnix(sockaddr
):
86 sock_unix
= Cast(sockaddr
, 'sockaddr_un *')
90 if (len(str(sock_unix
.sun_path
)) > 0):
91 return str(sock_unix
.sun_path
)
95 def GetInAddrAsString(ia
):
97 inaddr
= Cast(ia
, 'in_addr *')
99 packed_value
= struct
.pack('I', unsigned(ia
.s_addr
))
100 out_string
= inet_ntoa(packed_value
)
103 def GetIn6AddrAsString(ia
):
107 addr_format_string
= "{0:02x}:{1:02x}:{2:02x}:{3:02x}{4:02x}:{5:02x}:{6:02x}:{7:02x}{8:02x}:{9:02x}:{10:02x}:{11:02x}{12:02x}:{13:02x}:{14:02x}:{15:02x}"
108 out_string
+= addr_format_string
.format(unsigned(addr
[0]), unsigned(addr
[1]), unsigned(addr
[2]), unsigned(addr
[3]), unsigned(addr
[4]), unsigned(addr
[5]), unsigned(addr
[6]), unsigned(addr
[7]), unsigned(addr
[8]), unsigned(addr
[9]), unsigned(addr
[10]), unsigned(addr
[11]), unsigned(addr
[12]), unsigned(addr
[13]), unsigned(addr
[14]), unsigned(addr
[15]))
111 def GetSocketAddrAsStringInet(sockaddr
):
112 sock_in
= Cast(sockaddr
, 'sockaddr_in *')
113 return GetInAddrAsString(sock_in
.sin_addr
)
115 def GetSocketAddrAsStringInet6(sockaddr
):
116 sock_in6
= Cast(sockaddr
, 'sockaddr_in6 *')
117 return GetIn6AddrAsString(sock_in6
.sin6_addr
.__u6_addr
.__u6_addr
8)
119 def GetSocketAddrAsStringLink(sockaddr
):
120 sock_link
= Cast(sockaddr
, 'sockaddr_dl *')
121 if sock_link
is None:
125 if (sock_link
.sdl_nlen
== 0 and sock_link
.sdl_alen
== 0 and sock_link
.sdl_slen
== 0):
126 out_string
= "link#" + str(int(sock_link
.sdl_index
))
128 out_string
+= GetAddressAsStringColonHex(addressof(sock_link
.sdl_data
[sock_link
.sdl_nlen
]), sock_link
.sdl_alen
)
131 def GetSocketAddrAsStringAT(sockaddr
):
133 sock_addr
= Cast(sockaddr
, 'sockaddr *')
134 out_string
+= GetAddressAsStringColonHex(sockaddr
.sa_data
, sockaddr
.sa_len
- 2)
137 def GetSocketAddrAsString(sockaddr
):
138 if sockaddr
is None :
141 if (sockaddr
.sa_family
== 0):
142 out_string
+= "UNSPC "
143 GetSocketAddrAsStringUnspec(sockaddr
)
144 elif (sockaddr
.sa_family
== 1):
145 out_string
+= "UNIX "
146 out_string
+= GetSocketAddrAsStringUnix(sockaddr
)
147 elif (sockaddr
.sa_family
== 2):
148 out_string
+= "INET "
149 out_string
+= GetSocketAddrAsStringInet(sockaddr
)
150 elif (sockaddr
.sa_family
== 30):
151 out_string
+= "INET6 "
152 out_string
+= GetSocketAddrAsStringInet6(sockaddr
)
153 elif (sockaddr
.sa_family
== 18):
154 out_string
+= "LINK "
155 out_string
+= GetSocketAddrAsStringLink(sockaddr
)
156 elif (sockaddr
.sa_family
== 16):
157 out_string
+= "ATLK "
158 out_string
+= GetSocketAddrAsStringAT(sockaddr
)
160 out_string
+= "FAM " + str(sockaddr
.sa_family
)
161 out_string
+= GetAddressAsStringColonHex(sockaddr
.sa_data
, sockaddr
.sa_len
)
165 @lldb_command('showifaddrs')
166 def ShowIfaddrs(cmd_args
=None):
167 """ Show the (struct ifnet).if_addrhead list of addresses for the given ifp
169 if cmd_args
!= None and len(cmd_args
) > 0 :
170 ifp
= kern
.GetValueFromAddress(cmd_args
[0], 'ifnet *')
172 print "Unknown value passed as argument."
175 for ifaddr
in IterateTAILQ_HEAD(ifp
.if_addrhead
, "ifa_link"):
176 format_string
= "\t{0: <d}: 0x{1: <x} {2: <s} [{3: <d}]"
177 print format_string
.format(i
, ifaddr
, GetSocketAddrAsString(ifaddr
.ifa_addr
), ifaddr
.ifa_refcnt
)
180 print "Missing argument 0 in user function."
181 # EndMacro: showifaddrs
187 for ifaddr
in IterateTAILQ_HEAD(ifp
.if_addrhead
, "ifa_link"):
188 format_string
= "\t{0: <d}: 0x{1: <x} {2: <s} [{3: <d}]"
189 out_string
+= format_string
.format(i
, ifaddr
, GetSocketAddrAsString(ifaddr
.ifa_addr
), ifaddr
.ifa_refcnt
) + "\n"
192 out_string
+= "Missing argument 0 in user function."
196 def GetCapabilitiesAsString(flags
):
197 """ Return a formatted string description of the interface flags
204 out_string
+= if_capenable_strings
[i
] + ","
207 return rstrip(out_string
, ",")
209 def GetIfEflagsAsString(if_eflags
):
210 """ Return a formatted string description of the interface flags
213 flags
= unsigned(if_eflags
)
218 out_string
+= if_eflags_strings
[i
] + ","
221 return rstrip(out_string
, ",")
223 def ShowDlilIfnetConfiguration(dlil_ifnet
, show_all
) :
224 """ Formatted display of dlil_ifnet structures
229 if dlil_ifnet
is None :
232 dlil_iface
= Cast(dlil_ifnet
, 'dlil_ifnet *')
233 iface
= Cast(dlil_ifnet
, 'ifnet *')
235 if (dlil_iface
.dl_if_flags
& DLIF_REUSE
) :
237 format_string
= "{0: <s}: flags={1: <x} <{2: <s}> index {3: <d} mtu {4: <d}"
238 extended_flags_format_string
= "\n\teflags={0: <x} <{1: <s}>"
239 capenabled_format_string
= "\n\toptions={0: <x} <{1: <s}>"
240 if (dlil_iface
.dl_if_flags
& DLIF_INUSE
) :
241 out_string
+= format_string
.format(iface
.if_xname
, (iface
.if_flags
& 0xffff), GetIfFlagsAsString(iface
.if_flags
), iface
.if_index
, iface
.if_data
.ifi_mtu
)
243 out_string
+= format_string
.format("[" + str(iface
.if_name
) + str(int(iface
.if_unit
)) + "]", (iface
.if_flags
& 0xffff), GetIfFlagsAsString(iface
.if_flags
), iface
.if_index
, iface
.if_data
.ifi_mtu
)
244 if (iface
.if_eflags
) :
245 out_string
+= extended_flags_format_string
.format(iface
.if_eflags
, GetIfEflagsAsString(iface
.if_eflags
))
246 if (iface
.if_capenable
) :
247 out_string
+= capenabled_format_string
.format(iface
.if_capenable
, GetCapabilitiesAsString(iface
.if_capenable
))
248 out_string
+= "\n\t(struct ifnet *)" + hex(dlil_ifnet
) + "\n"
250 out_string
+= GetIfaddrs(iface
)
255 @lldb_command('showifnets')
256 def ShowIfnets(cmd_args
=None) :
257 """ Display ifconfig-like output for all attached and detached interfaces
260 if cmd_args
!= None and len(cmd_args
) > 0 :
262 dlil_ifnets
= kern
.globals.dlil_ifnet_head
263 for dlil_ifnet
in IterateTAILQ_HEAD(dlil_ifnets
, "dl_if_link"):
264 ShowDlilIfnetConfiguration(dlil_ifnet
, showall
)
265 # EndMacro: showifnets
267 # Macro: showifmultiaddrs
268 @lldb_command('showifmultiaddrs')
269 def ShowIfMultiAddrs(cmd_args
=None) :
270 """ Show the list of multicast addresses for the given ifp
273 if cmd_args
!= None and len(cmd_args
) > 0 :
274 ifp
= kern
.GetValueFromAddress(cmd_args
[0], 'ifnet *')
276 print "Unknown value passed as argument."
278 ifmulti
= cast(ifp
.if_multiaddrs
.lh_first
, 'ifmultiaddr *')
281 ifma_format_string
= "\t{0: <d}: 0x{1: <x} "
282 out_string
+= (ifma_format_string
.format(i
+ 1, ifmulti
))
283 if (ifmulti
.ifma_addr
.sa_family
== 2):
284 if (ifmulti
.ifma_ll
!= 0):
285 out_string
+= GetSocketAddrAsStringLink(ifmulti
.ifma_ll
.ifma_addr
) + " "
286 out_string
+= GetSocketAddrAsStringInet(ifmulti
.ifma_addr
)
287 if (ifmulti
.ifma_addr
.sa_family
== 30):
288 if (ifmulti
.ifma_ll
!= 0):
289 out_string
+= GetSocketAddrAsStringLink(ifmulti
.ifma_ll
.ifma_addr
) + " "
290 out_string
+= GetSocketAddrAsStringInet6(ifmulti
.ifma_addr
) + " "
291 if (ifmulti
.ifma_addr
.sa_family
== 18):
292 out_string
+= GetSocketAddrAsStringLink(ifmulti
.ifma_addr
) + " "
293 if (ifmulti
.ifma_addr
.sa_family
== 0):
294 out_string
+= GetSocketAddrAsStringUnspec(ifmulti
.ifma_addr
) + " "
295 out_string
+= "[" + str(int(ifmulti
.ifma_refcount
)) + "]\n"
296 ifmulti
= cast(ifmulti
.ifma_link
.le_next
, 'ifmultiaddr *')
300 print "Missing argument 0 in user function."
301 # EndMacro: showifmultiaddrs
303 # Macro: showinmultiaddrs
304 @lldb_command('showinmultiaddrs')
305 def ShowInMultiAddrs(cmd_args
=None) :
306 """ Show the contents of IPv4 multicast address records
309 inmultihead
= kern
.globals.in_multihead
310 inmulti
= cast(inmultihead
.lh_first
, 'in_multi *')
313 ifp
= inmulti
.inm_ifp
314 inma_format_string
= "\t{0: <d}: 0x{1: <x} "
315 out_string
+= inma_format_string
.format(i
+ 1, inmulti
) + " "
316 out_string
+= GetInAddrAsString(addressof(inmulti
.inm_addr
)) + " "
317 ifma_format_string
= "(ifp 0x{0: <x} [{1: <s}] ifma {2: <x})"
318 out_string
+= ifma_format_string
.format(ifp
, ifp
.if_xname
, inmulti
.inm_ifma
) + "\n"
319 inmulti
= cast(inmulti
.inm_link
.le_next
, 'in_multi *')
322 # EndMacro: showinmultiaddrs
324 # Macro: showin6multiaddrs
325 @lldb_command('showin6multiaddrs')
326 def ShowIn6MultiAddrs(cmd_args
=None) :
327 """ Show the contents of IPv6 multicast address records
330 in6multihead
= kern
.globals.in6_multihead
331 in6multi
= cast(in6multihead
.lh_first
, 'in6_multi *')
334 ifp
= in6multi
.in6m_ifp
335 inma_format_string
= "\t{0: <d}: 0x{1: <x} "
336 out_string
+= inma_format_string
.format(i
+ 1, in6multi
) + " "
337 out_string
+= GetIn6AddrAsString((in6multi
.in6m_addr
.__u6_addr
.__u6_addr
8)) + " "
338 ifma_format_string
= "(ifp 0x{0: <x} [{1: <s}] ifma {2: <x})"
339 out_string
+= ifma_format_string
.format(ifp
, ifp
.if_xname
, in6multi
.in6m_ifma
) + "\n"
340 in6multi
= cast(in6multi
.in6m_entry
.le_next
, 'in6_multi *')
343 # EndMacro: showin6multiaddrs
345 def GetTcpState(tcpcb
):
347 tp
= Cast(tcpcb
, 'tcpcb *')
350 out_string
+= "CLOSED\t"
352 out_string
+= "LISTEN\t"
354 out_string
+= "SYN_SENT\t"
356 out_string
+= "SYN_RCVD\t"
358 out_string
+= "ESTABLISHED\t"
360 out_string
+= "CLOSE_WAIT\t"
362 out_string
+= "FIN_WAIT_1\t"
364 out_string
+= "CLOSING\t"
366 out_string
+= "LAST_ACK\t"
368 out_string
+= "FIN_WAIT_2\t"
370 out_string
+= "TIME_WAIT\t"
373 def GetSocketProtocolAsString(sock
):
375 inpcb
= Cast(sock
.so_pcb
, 'inpcb *')
376 if sock
.so_proto
.pr_protocol
== 6:
377 out_string
+= " TCP "
378 out_string
+= GetTcpState(inpcb
.inp_ppcb
)
379 if sock
.so_proto
.pr_protocol
== 17:
380 out_string
+= " UDP "
381 if sock
.so_proto
.pr_protocol
== 1:
382 out_string
+= " ICMP "
383 if sock
.so_proto
.pr_protocol
== 254:
384 out_string
+= " DIVERT "
385 if sock
.so_proto
.pr_protocol
== 255:
386 out_string
+= " RAW "
389 def GetInAddr4to6AsString(inaddr
):
391 if (inaddr
is not None):
392 ia
= Cast(inaddr
, 'char *')
393 inaddr_format_string
= "{0: <d}.{1: <d}.{2: <d}.{3: <d}"
394 out_string
+= inaddr_format_string
.format(ia
[0], ia
[1], ia
[2], ia
[3])
397 def GetInPortAsString(port
):
399 port_string
= Cast(port
, 'char *')
400 port_unsigned
= dereference(Cast(port
, 'unsigned short *'))
402 if ((((port_unsigned
& 0xff00) >> 8) == port_string
[0])) and (((port_unsigned
& 0x00ff) == port_string
[1])):
403 out_string
+= ":" + str(int(port_unsigned
))
405 out_string
+= ":" + str(int(((port_unsigned
& 0xff00) >> 8) |
((port_unsigned
& 0x00ff) << 8)))
409 def GetIPv4SocketAsString(sock
) :
411 pcb
= Cast(sock
.so_pcb
, 'inpcb *')
413 out_string
+= "inpcb: (null) "
415 out_string
+= "inpcb: " + hex(pcb
)
416 out_string
+= GetSocketProtocolAsString(sock
)
418 out_string
+= GetInAddr4to6AsString(addressof(pcb
.inp_dependladdr
.inp46_local
))
419 out_string
+= GetInPortAsString(addressof(pcb
.inp_lport
))
421 out_string
+= GetInAddr4to6AsString(addressof(pcb
.inp_dependfaddr
.inp46_foreign
))
422 out_string
+= GetInPortAsString(addressof(pcb
.inp_fport
))
425 def GetIPv6SocketAsString(sock
) :
427 pcb
= Cast(sock
.so_pcb
, 'inpcb *')
429 out_string
+= "inpcb: (null) "
431 out_string
+= "inpcb: " + hex(pcb
) + " "
432 out_string
+= GetSocketProtocolAsString(sock
)
434 out_string
+= GetIn6AddrAsString((pcb
.inp_dependladdr
.inp6_local
.__u6_addr
.__u6_addr
8))
435 out_string
+= GetInPortAsString(addressof(pcb
.inp_lport
))
437 out_string
+= GetIn6AddrAsString((pcb
.inp_dependfaddr
.inp6_foreign
.__u6_addr
.__u6_addr
8))
438 out_string
+= GetInPortAsString(addressof(pcb
.inp_fport
))
441 def GetUnixDomainSocketAsString(sock
) :
443 pcb
= Cast(sock
.so_pcb
, 'unpcb *')
445 out_string
+= "unpcb: (null) "
447 out_string
+= "unpcb: " + hex(pcb
) + " "
448 out_string
+= "unp_vnode: " + hex(pcb
.unp_vnode
) + " "
449 out_string
+= "unp_conn: " + hex(pcb
.unp_conn
) + " "
450 out_string
+= "unp_addr: " + GetSocketAddrAsStringUnix(pcb
.unp_addr
)
453 def GetSocket(socket
) :
454 """ Show the contents of a socket
456 so
= kern
.GetValueFromAddress(unsigned(socket
), 'socket *')
459 sock_format_string
= "so: 0x{0:<x}"
460 out_string
+= sock_format_string
.format(so
)
461 domain
= so
.so_proto
.pr_domain
462 domain_name_format_string
= " {0:<s} "
463 out_string
+= domain_name_format_string
.format(domain
.dom_name
)
464 if (domain
.dom_family
== 1):
465 out_string
+= GetUnixDomainSocketAsString(so
)
466 if (domain
.dom_family
== 2):
467 out_string
+= GetIPv4SocketAsString(so
)
468 if (domain
.dom_family
== 30):
469 out_string
+= GetIPv6SocketAsString(so
)
471 out_string
+= "(null)"
473 # EndMacro: showsocket
477 @lldb_command('showsocket')
478 def ShowSocket(cmd_args
=None) :
479 """ Show the contents of a socket
481 if (cmd_args
== None or len(cmd_args
) == 0):
482 print "Missing argument 0 in user function."
484 so
= kern
.GetValueFromAddress(cmd_args
[0], 'socket *')
485 if (len(str(cmd_args
[0])) > 0):
487 sock_format_string
= "so: 0x{0:<x}"
488 out_string
+= sock_format_string
.format(so
)
489 domain
= so
.so_proto
.pr_domain
490 domain_name_format_string
= " {0:<s} "
491 out_string
+= domain_name_format_string
.format(domain
.dom_name
)
492 if (domain
.dom_family
== 1):
493 out_string
+= GetUnixDomainSocketAsString(so
)
494 if (domain
.dom_family
== 2):
495 out_string
+= GetIPv4SocketAsString(so
)
496 if (domain
.dom_family
== 30):
497 out_string
+= GetIPv6SocketAsString(so
)
500 print "Unknown value passed as argument."
502 # EndMacro: showsocket
504 # Macro: showprocsockets
505 @lldb_command('showprocsockets')
506 def ShowProcSockets(cmd_args
=None):
507 """ Given a proc_t pointer, display information about its sockets
511 if cmd_args
!= None and len(cmd_args
) > 0 :
512 proc
= kern
.GetValueFromAddress(cmd_args
[0], 'proc *')
516 print "Unknown value passed as argument."
520 fpp
= Cast(proc_fd
.fd_ofiles
, 'fileproc **')
521 while (count
< proc_fd
.fd_nfiles
):
522 fp
= Cast(dereference(fpp
), 'fileproc *')
524 fg
= Cast(fp
.f_fglob
, 'fileglob *')
525 if (int(fg
.fg_ops
.fo_type
) == 2):
526 if (proc_fd
.fd_ofileflags
[count
] & 4):
530 out_string
+= "fd = " + str(count
) + " "
531 if (fg
.fg_data
!= 0):
532 out_string
+= GetSocket(unsigned(fg
.fg_data
))
536 fpp
= kern
.GetValueFromAddress(unsigned(fpp
+ 8), 'fileproc **')
540 print "Missing argument 0 in user function."
541 # EndMacro: showprocsockets
543 def GetProcSockets(proc
):
544 """ Given a proc_t pointer, display information about its sockets
550 out_string
+= "Unknown value passed as argument."
553 fpp
= Cast(proc_fd
.fd_ofiles
, 'fileproc **')
554 while (count
< proc_fd
.fd_nfiles
):
555 fp
= Cast(dereference(fpp
), 'fileproc *')
557 fg
= Cast(fp
.f_fglob
, 'fileglob *')
558 if (int(fg
.fg_ops
.fo_type
) == 2):
559 if (proc_fd
.fd_ofileflags
[count
] & 4):
563 out_string
+= "fd = " + str(count
) + " "
564 if (fg
.fg_data
!= 0):
565 out_string
+= GetSocket(unsigned(fg
.fg_data
))
569 fpp
= kern
.GetValueFromAddress(unsigned(fpp
+ 8), 'fileproc **')
574 # Macro: showallprocsockets
575 @lldb_command('showallprocsockets')
576 def ShowAllProcSockets(cmd_args
=None):
577 """Display information about the sockets of all the processes
579 for proc
in kern
.procs
:
580 print "================================================================================"
581 print GetProcInfo(proc
)
582 print GetProcSockets(proc
)
583 # EndMacro: showallprocsockets
586 def GetRtEntryPrDetailsAsString(rte
):
588 rt
= Cast(rte
, 'rtentry *')
589 dst
= Cast(rt
.rt_nodes
[0].rn_u
.rn_leaf
.rn_Key
, 'sockaddr *')
591 dst_string_format
= "{0:<18s}"
592 if (dst
.sa_family
== AF_INET
):
593 out_string
+= dst_string_format
.format(GetSocketAddrAsStringInet(dst
)) + " "
595 if (dst
.sa_family
== AF_INET6
):
596 out_string
+= dst_string_format
.format(GetSocketAddrAsStringInet6(dst
)) + " "
599 if (dst
.sa_family
== AF_LINK
):
600 out_string
+= dst_string_format
.format(GetSocketAddrAsStringLink(dst
))
606 out_string
+= dst_string_format
.format(GetSocketAddrAsStringUnspec(dst
)) + " "
608 gw
= Cast(rt
.rt_gateway
, 'sockaddr *')
609 if (gw
.sa_family
== AF_INET
):
610 out_string
+= dst_string_format
.format(GetSocketAddrAsStringInet(gw
)) + " "
612 if (gw
.sa_family
== 30):
613 out_string
+= dst_string_format
.format(GetSocketAddrAsStringInet6(gw
)) + " "
616 if (gw
.sa_family
== 18):
617 out_string
+= dst_string_format
.format(GetSocketAddrAsStringLink(gw
)) + " "
623 dst_string_format
.format(GetSocketAddrAsStringUnspec(gw
))
625 if (rt
.rt_flags
& RTF_WASCLONED
):
626 if (kern
.ptrsize
== 8):
627 rt_flags_string_format
= "0x{0:<16x}"
628 out_string
+= rt_flags_string_format
.format(rt
.rt_parent
) + " "
630 rt_flags_string_format
= "0x{0:<8x}"
631 out_string
+= rt_flags_string_format
.format(rt
.rt_parent
) + " "
633 if (kern
.ptrsize
== 8):
638 rt_refcnt_rmx_string_format
= "{0:<d} {1:>10d} "
639 out_string
+= rt_refcnt_rmx_string_format
.format(rt
.rt_refcnt
, rt
.rt_rmx
.rmx_pksent
) + " "
641 rtf_string_format
= "{0:>s}"
642 if (rt
.rt_flags
& RTF_UP
):
643 out_string
+= rtf_string_format
.format("U")
644 if (rt
.rt_flags
& RTF_GATEWAY
):
645 out_string
+= rtf_string_format
.format("G")
646 if (rt
.rt_flags
& RTF_HOST
):
647 out_string
+= rtf_string_format
.format("H")
648 if (rt
.rt_flags
& RTF_REJECT
):
649 out_string
+= rtf_string_format
.format("R")
650 if (rt
.rt_flags
& RTF_DYNAMIC
):
651 out_string
+= rtf_string_format
.format("D")
652 if (rt
.rt_flags
& RTF_MODIFIED
):
653 out_string
+= rtf_string_format
.format("M")
654 if (rt
.rt_flags
& RTF_CLONING
):
655 out_string
+= rtf_string_format
.format("C")
656 if (rt
.rt_flags
& RTF_PRCLONING
):
657 out_string
+= rtf_string_format
.format("c")
658 if (rt
.rt_flags
& RTF_LLINFO
):
659 out_string
+= rtf_string_format
.format("L")
660 if (rt
.rt_flags
& RTF_STATIC
):
661 out_string
+= rtf_string_format
.format("S")
662 if (rt
.rt_flags
& RTF_PROTO1
):
663 out_string
+= rtf_string_format
.format("1")
664 if (rt
.rt_flags
& RTF_PROTO2
):
665 out_string
+= rtf_string_format
.format("2")
666 if (rt
.rt_flags
& RTF_PROTO3
):
667 out_string
+= rtf_string_format
.format("3")
668 if (rt
.rt_flags
& RTF_WASCLONED
):
669 out_string
+= rtf_string_format
.format("W")
670 if (rt
.rt_flags
& RTF_BROADCAST
):
671 out_string
+= rtf_string_format
.format("b")
672 if (rt
.rt_flags
& RTF_MULTICAST
):
673 out_string
+= rtf_string_format
.format("m")
674 if (rt
.rt_flags
& RTF_XRESOLVE
):
675 out_string
+= rtf_string_format
.format("X")
676 if (rt
.rt_flags
& RTF_BLACKHOLE
):
677 out_string
+= rtf_string_format
.format("B")
678 if (rt
.rt_flags
& RTF_IFSCOPE
):
679 out_string
+= rtf_string_format
.format("I")
680 if (rt
.rt_flags
& RTF_CONDEMNED
):
681 out_string
+= rtf_string_format
.format("Z")
682 if (rt
.rt_flags
& RTF_IFREF
):
683 out_string
+= rtf_string_format
.format("i")
684 if (rt
.rt_flags
& RTF_PROXY
):
685 out_string
+= rtf_string_format
.format("Y")
686 if (rt
.rt_flags
& RTF_ROUTER
):
687 out_string
+= rtf_string_format
.format("r")
690 out_string
+= str(rt
.rt_ifp
.if_name
)
691 out_string
+= str(int(rt
.rt_ifp
.if_unit
))
697 def GetRtTableAsString(rt_tables
):
699 rn
= Cast(rt_tables
.rnh_treetop
, 'radix_node *')
700 rnh_cnt
= rt_tables
.rnh_cnt
702 while (rn
.rn_bit
>= 0):
703 rn
= rn
.rn_u
.rn_node
.rn_L
706 base
= Cast(rn
, 'radix_node *')
707 while ((rn
.rn_parent
.rn_u
.rn_node
.rn_R
== rn
) and (rn
.rn_flags
& RNF_ROOT
== 0)):
709 rn
= rn
.rn_parent
.rn_u
.rn_node
.rn_R
710 while (rn
.rn_bit
>= 0):
711 rn
= rn
.rn_u
.rn_node
.rn_L
715 base
= rn
.rn_u
.rn_leaf
.rn_Dupedkey
716 if ((rn
.rn_flags
& RNF_ROOT
) == 0):
717 rt
= Cast(rn
, 'rtentry *')
718 if (kern
.ptrsize
== 8):
719 rtentry_string_format
= "0x{0:<18x}"
720 out_string
+= rtentry_string_format
.format(rt
) + " "
722 rtentry_string_format
= "0x{0:<10x}"
723 out_string
+= rtentry_string_format
.format(rt
) + " "
724 out_string
+= GetRtEntryPrDetailsAsString(rt
) + " "
727 if ((rn
.rn_flags
& RNF_ROOT
) != 0):
731 def GetRtInetAsString():
732 rt_tables
= kern
.globals.rt_tables
[2]
733 if (kern
.ptrsize
== 8):
734 rt_table_header_format_string
= "{0:<18s} {1: <16s} {2:<20s} {3:<16s} {4:<8s} {5:<8s} {6:<8s}"
735 print rt_table_header_format_string
.format("rtentry", " dst", "gw", "parent", "Refs", "Use", "flags/if")
736 print rt_table_header_format_string
.format("-" * 18, "-" * 16, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8)
737 print GetRtTableAsString(rt_tables
)
739 rt_table_header_format_string
= "{0:<8s} {1:<16s} {2:<18s} {3:<8s} {4:<8s} {5:<8s} {6:<8s}"
740 print rt_table_header_format_string
.format("rtentry", "dst", "gw", "parent", "Refs", "Use", "flags/if")
741 print rt_table_header_format_string
.format("-" * 8, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8, "-" * 8)
742 print GetRtTableAsString(rt_tables
)
744 def GetRtInet6AsString():
745 rt_tables
= kern
.globals.rt_tables
[30]
746 if (kern
.ptrsize
== 8):
747 rt_table_header_format_string
= "{0:<18s} {1: <16s} {2:<20s} {3:<16s} {4:<8s} {5:<8s} {6:<8s}"
748 print rt_table_header_format_string
.format("rtentry", " dst", "gw", "parent", "Refs", "Use", "flags/if")
749 print rt_table_header_format_string
.format("-" * 18, "-" * 16, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8)
750 print GetRtTableAsString(rt_tables
)
752 rt_table_header_format_string
= "{0:<8s} {1:<16s} {2:<18s} {3:<8s} {4:<8s} {5:<8s} {6:<8s}"
753 print rt_table_header_format_string
.format("rtentry", "dst", "gw", "parent", "Refs", "Use", "flags/if")
754 print rt_table_header_format_string
.format("-" * 8, "-" * 16, "-" * 18, "-" * 8, "-" * 8, "-" * 8, "-" * 8)
755 print GetRtTableAsString(rt_tables
)
757 # Macro: show_rt_inet
758 @lldb_command('show_rt_inet')
759 def ShowRtInet(cmd_args
=None):
760 """ Display the IPv4 routing table
762 print GetRtInetAsString()
763 # EndMacro: show_rt_inet
765 # Macro: show_rt_inet6
766 @lldb_command('show_rt_inet6')
767 def ShowRtInet6(cmd_args
=None):
768 """ Display the IPv6 routing table
770 print GetRtInet6AsString()
771 # EndMacro: show_rt_inet6
773 # Macro: rtentry_showdbg
774 @lldb_command('rtentry_showdbg')
775 def ShowRtEntryDebug(cmd_args
=None):
776 """ Print the debug information of a route entry
778 if (cmd_args
== None or len(cmd_args
) == 0):
779 print "Missing argument 0 in user function."
783 rtd
= kern
.GetValueFromAddress(cmd_args
[0], 'rtentry_dbg *')
784 rtd_summary_format_string
= "{0:s} {1:d}"
785 out_string
+= rtd_summary_format_string
.format("Total holds : ", rtd
.rtd_refhold_cnt
) + "\n"
786 out_string
+= rtd_summary_format_string
.format("Total releases : ", rtd
.rtd_refrele_cnt
) + "\n"
789 while (ix
< CTRACE_STACK_SIZE
):
790 kgm_pc
= rtd
.rtd_alloc
.pc
[ix
]
793 out_string
+= "\nAlloc: (thread " + hex(rtd
.rtd_alloc
.th
) + "):\n"
794 out_string
+= str(int(ix
+ 1)) + ": "
795 out_string
+= GetSourceInformationForAddress(kgm_pc
)
800 while (ix
< CTRACE_STACK_SIZE
):
801 kgm_pc
= rtd
.rtd_free
.pc
[ix
]
804 out_string
+= "\nFree: (thread " + hex(rtd
.rtd_free
.th
) + "):\n"
805 out_string
+= str(int(ix
+ 1)) + ": "
806 out_string
+= GetSourceInformationForAddress(kgm_pc
)
810 while (cnt
< RTD_TRACE_HIST_SIZE
):
812 while (ix
< CTRACE_STACK_SIZE
):
813 kgm_pc
= rtd
.rtd_refhold
[cnt
].pc
[ix
]
816 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(rtd
.rtd_refhold
[cnt
].th
) + "):\n"
817 out_string
+= str(int(ix
+ 1)) + ": "
818 out_string
+= GetSourceInformationForAddress(kgm_pc
)
824 while (cnt
< RTD_TRACE_HIST_SIZE
):
826 while (ix
< CTRACE_STACK_SIZE
):
827 kgm_pc
= rtd
.rtd_refrele
[cnt
].pc
[ix
]
830 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(rtd
.rtd_refrele
[cnt
].th
) + "):\n"
831 out_string
+= str(int(ix
+ 1)) + ": "
832 out_string
+= GetSourceInformationForAddress(kgm_pc
)
837 out_string
+= "\nTotal locks : " + str(int(rtd
.rtd_lock_cnt
))
838 out_string
+= "\nTotal unlocks : " + str(int(rtd
.rtd_unlock_cnt
))
841 while (cnt
< RTD_TRACE_HIST_SIZE
):
843 while (ix
< CTRACE_STACK_SIZE
):
844 kgm_pc
= rtd
.rtd_lock
[cnt
].pc
[ix
]
847 out_string
+= "\nLock [" + str(int(cnt
)) + "] (thread " + hex(rtd
.rtd_lock
[cnt
].th
) + "):\n"
848 out_string
+= str(int(ix
+ 1)) + ": "
849 out_string
+= GetSourceInformationForAddress(kgm_pc
)
855 while (cnt
< RTD_TRACE_HIST_SIZE
):
857 while (ix
< CTRACE_STACK_SIZE
):
858 kgm_pc
= rtd
.rtd_unlock
[cnt
].pc
[ix
]
861 out_string
+= "\nUnlock [" + str(int(cnt
)) + "] (thread " + hex(rtd
.rtd_unlock
[cnt
].th
) + "):\n"
862 out_string
+= str(int(ix
+ 1)) + ": "
863 out_string
+= GetSourceInformationForAddress(kgm_pc
)
869 # EndMacro: rtentry_showdbg
871 # Macro: inifa_showdbg
872 @lldb_command('inifa_showdbg')
873 def InIfaShowDebug(cmd_args
=None):
874 """ Print the debug information of an IPv4 interface address
876 if (cmd_args
== None or len(cmd_args
) == 0):
877 print "Missing argument 0 in user function."
881 inifa
= kern
.GetValueFromAddress(cmd_args
[0], 'in_ifaddr_dbg *')
882 in_ifaddr_summary_format_string
= "{0:s} {1:d}"
883 out_string
+= in_ifaddr_summary_format_string
.format("Total holds : ", inifa
.inifa_refhold_cnt
) + "\n"
884 out_string
+= in_ifaddr_summary_format_string
.format("Total releases : ", inifa
.inifa_refrele_cnt
) + "\n"
887 while (ix
< CTRACE_STACK_SIZE
):
888 kgm_pc
= inifa
.inifa_alloc
.pc
[ix
]
891 out_string
+= "\nAlloc: (thread " + hex(inifa
.inifa_alloc
.th
) + "):\n"
892 out_string
+= str(int(ix
+ 1)) + ": "
893 out_string
+= GetSourceInformationForAddress(kgm_pc
)
898 while (ix
< CTRACE_STACK_SIZE
):
899 kgm_pc
= inifa
.inifa_free
.pc
[ix
]
902 out_string
+= "\nFree: (thread " + hex(inifa
.inifa_free
.th
) + "):\n"
903 out_string
+= str(int(ix
+ 1)) + ": "
904 out_string
+= GetSourceInformationForAddress(kgm_pc
)
908 while (cnt
< INIFA_TRACE_HIST_SIZE
):
910 while (ix
< CTRACE_STACK_SIZE
):
911 kgm_pc
= inifa
.inifa_refhold
[cnt
].pc
[ix
]
914 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(inifa
.inifa_refhold
[cnt
].th
) + "):\n"
915 out_string
+= str(int(ix
+ 1)) + ": "
916 out_string
+= GetSourceInformationForAddress(kgm_pc
)
922 while (cnt
< INIFA_TRACE_HIST_SIZE
):
924 while (ix
< CTRACE_STACK_SIZE
):
925 kgm_pc
= inifa
.inifa_refrele
[cnt
].pc
[ix
]
928 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(inifa
.inifa_refrele
[cnt
].th
) + "):\n"
929 out_string
+= str(int(ix
+ 1)) + ": "
930 out_string
+= GetSourceInformationForAddress(kgm_pc
)
935 # EndMacro: inifa_showdbg
937 # Macro: in6ifa_showdbg
938 @lldb_command('in6ifa_showdbg')
939 def In6IfaShowDebug(cmd_args
=None):
940 """ Print the debug information of an IPv6 interface address
942 if (cmd_args
== None or len(cmd_args
) == 0):
943 print "Missing argument 0 in user function."
947 in6ifa
= kern
.GetValueFromAddress(cmd_args
[0], 'in6_ifaddr_dbg *')
948 in6_ifaddr_summary_format_string
= "{0:s} {1:d}"
949 print in6_ifaddr_summary_format_string
.format("Total holds : ", in6ifa
.in6ifa_refhold_cnt
)
950 print in6_ifaddr_summary_format_string
.format("Total releases : ", in6ifa
.in6ifa_refrele_cnt
)
953 while (ix
< CTRACE_STACK_SIZE
):
954 kgm_pc
= in6ifa
.in6ifa_alloc
.pc
[ix
]
957 out_string
+= "\nAlloc: (thread " + hex(in6ifa
.in6ifa_alloc
.th
) + "):\n"
958 out_string
+= str(int(ix
+ 1)) + ": "
959 out_string
+= GetSourceInformationForAddress(kgm_pc
)
964 while (ix
< CTRACE_STACK_SIZE
):
965 kgm_pc
= in6ifa
.in6ifa_free
.pc
[ix
]
968 out_string
+= "\nFree: (thread " + hex(in6ifa
.in6ifa_free
.th
) + "):\n"
969 out_string
+= str(int(ix
+ 1)) + ": "
970 out_string
+= GetSourceInformationForAddress(kgm_pc
)
974 while (cnt
< IN6IFA_TRACE_HIST_SIZE
):
976 while (ix
< CTRACE_STACK_SIZE
):
977 kgm_pc
= in6ifa
.in6ifa_refhold
[cnt
].pc
[ix
]
980 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(in6ifa
.in6ifa_refhold
[cnt
].th
) + "):\n"
981 out_string
+= str(int(ix
+ 1)) + ": "
982 out_string
+= GetSourceInformationForAddress(kgm_pc
)
988 while (cnt
< IN6IFA_TRACE_HIST_SIZE
):
990 while (ix
< CTRACE_STACK_SIZE
):
991 kgm_pc
= in6ifa
.in6ifa_refrele
[cnt
].pc
[ix
]
994 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(in6ifa
.in6ifa_refrele
[cnt
].th
) + "):\n"
995 out_string
+= str(int(ix
+ 1)) + ": "
996 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1001 # EndMacro: in6ifa_showdbg
1003 # Macro: inm_showdbg
1004 @lldb_command('inm_showdbg')
1005 def InmShowDebug(cmd_args
=None):
1006 """ Print the debug information of an IPv4 multicast address
1008 if (cmd_args
== None or len(cmd_args
) == 0):
1009 print "Missing argument 0 in user function."
1013 inm
= kern
.GetValueFromAddress(cmd_args
[0], 'in_multi_dbg *')
1014 in_multi_summary_format_string
= "{0:s} {1:d}"
1015 out_string
+= in_multi_summary_format_string
.format("Total holds : ", inm
.inm_refhold_cnt
)
1016 out_string
+= in_multi_summary_format_string
.format("Total releases : ", inm
.inm_refrele_cnt
)
1018 while (cnt
< INM_TRACE_HIST_SIZE
):
1020 while (ix
< CTRACE_STACK_SIZE
):
1021 kgm_pc
= inm
.inm_refhold
[cnt
].pc
[ix
]
1024 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(inm
.inm_refhold
[cnt
].th
) + "):\n"
1025 out_string
+= str(int(ix
+ 1)) + ": "
1026 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1031 while (cnt
< INM_TRACE_HIST_SIZE
):
1033 while (ix
< CTRACE_STACK_SIZE
):
1034 kgm_pc
= inm
.inm_refrele
[cnt
].pc
[ix
]
1037 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(inm
.inm_refrele
[cnt
].th
) + "):\n"
1038 out_string
+= str(int(ix
+ 1)) + ": "
1039 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1044 # EndMacro: inm_showdbg
1046 # Macro: ifma_showdbg
1047 @lldb_command('ifma_showdbg')
1048 def IfmaShowDebug(cmd_args
=None):
1049 """ Print the debug information of a link multicast address
1051 if (cmd_args
== None or len(cmd_args
) == 0):
1052 print "Missing argument 0 in user function."
1056 ifma
= kern
.GetValueFromAddress(cmd_args
[0], 'ifmultiaddr_dbg *')
1057 link_multi_summary_format_string
= "{0:s} {1:d}"
1058 out_string
+= link_multi_summary_format_string
.format("Total holds : ", ifma
.ifma_refhold_cnt
) + "\n"
1059 out_string
+= link_multi_summary_format_string
.format("Total releases : ", ifma
.ifma_refrele_cnt
) + "\n"
1061 while (cnt
< IFMA_TRACE_HIST_SIZE
):
1063 while (ix
< CTRACE_STACK_SIZE
):
1064 kgm_pc
= ifma
.ifma_refhold
[cnt
].pc
[ix
]
1067 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(ifma
.ifma_refhold
[cnt
].th
) + "):\n"
1068 out_string
+= str(int(ix
+ 1)) + ": "
1069 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1074 while (cnt
< IFMA_TRACE_HIST_SIZE
):
1076 while (ix
< CTRACE_STACK_SIZE
):
1077 kgm_pc
= ifma
.ifma_refrele
[cnt
].pc
[ix
]
1080 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(ifma
.ifma_refrele
[cnt
].th
) + "):\n"
1081 out_string
+= str(int(ix
+ 1)) + ": "
1082 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1087 # EndMacro: ifma_showdbg
1089 # Macro: ifpref_showdbg
1090 @lldb_command('ifpref_showdbg')
1091 def IfpRefShowDebug(cmd_args
=None):
1092 """ Print the debug information of an interface ref count
1094 if (cmd_args
== None or len(cmd_args
) == 0):
1095 print "Missing argument 0 in user function."
1099 dl_if
= kern
.GetValueFromAddress(cmd_args
[0], 'dlil_ifnet_dbg *')
1100 dl_if_summary_format_string
= "{0:s} {1:d}"
1101 out_string
+= dl_if_summary_format_string
.format("Total holds : ", dl_if
.dldbg_if_refhold_cnt
)
1102 out_string
+= dl_if_summary_format_string
.format("Total releases : ", dl_if
.dldbg_if_refrele_cnt
)
1104 while (cnt
< IF_REF_TRACE_HIST_SIZE
):
1106 while (ix
< CTRACE_STACK_SIZE
):
1107 kgm_pc
= dl_if
.dldbg_if_refhold
[cnt
].pc
[ix
]
1110 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(dl_if
.dldbg_if_refhold
[cnt
].th
) + "):\n"
1111 out_string
+= str(int(ix
+ 1)) + ": "
1112 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1117 while (cnt
< IF_REF_TRACE_HIST_SIZE
):
1119 while (ix
< CTRACE_STACK_SIZE
):
1120 kgm_pc
= dl_if
.dldbg_if_refrele
[cnt
].pc
[ix
]
1123 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(dl_if
.dldbg_if_refrele
[cnt
].th
) + "):\n"
1124 out_string
+= str(int(ix
+ 1)) + ": "
1125 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1130 # EndMacro: ifpref_showdbg
1132 # Macro: ndpr_showdbg
1133 @lldb_command('ndpr_showdbg')
1134 def ndprShowDebug(cmd_args
=None):
1135 """ Print the debug information of a nd_prefix structure
1137 if (cmd_args
== None or len(cmd_args
) == 0):
1138 print "Missing argument 0 in user function."
1142 ndpr
= kern
.GetValueFromAddress(cmd_args
[0], 'nd_prefix_dbg *')
1143 ndpr_summary_format_string
= "{0:s} {1:d}"
1144 out_string
+= ndpr_summary_format_string
.format("Total holds : ", ndpr
.ndpr_refhold_cnt
)
1145 out_string
+= ndpr_summary_format_string
.format("Total releases : ", ndpr
.ndpr_refrele_cnt
)
1147 while (cnt
< NDPR_TRACE_HIST_SIZE
):
1149 while (ix
< CTRACE_STACK_SIZE
):
1150 kgm_pc
= ndpr
.ndpr_refhold
[cnt
].pc
[ix
]
1153 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(ndpr
.ndpr_refhold
[cnt
].th
) + "):\n"
1154 out_string
+= str(int(ix
+ 1)) + ": "
1155 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1160 while (cnt
< NDPR_TRACE_HIST_SIZE
):
1162 while (ix
< CTRACE_STACK_SIZE
):
1163 kgm_pc
= ndpr
.ndpr_refrele
[cnt
].pc
[ix
]
1166 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(ndpr
.ndpr_refrele
[cnt
].th
) + "):\n"
1167 out_string
+= str(int(ix
+ 1)) + ": "
1168 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1173 # EndMacro: ndpr_showdbg
1175 # Macro: nddr_showdbg
1176 @lldb_command('nddr_showdbg')
1177 def nddrShowDebug(cmd_args
=None):
1178 """ Print the debug information of a nd_defrouter structure
1180 if (cmd_args
== None or len(cmd_args
) == 0):
1181 print "Missing argument 0 in user function."
1185 nddr
= kern
.GetValueFromAddress(cmd_args
[0], 'nd_defrouter_dbg *')
1186 nddr_summary_format_string
= "{0:s} {1:d}"
1187 out_string
+= nddr_summary_format_string
.format("Total holds : ", nddr
.nddr_refhold_cnt
)
1188 out_string
+= nddr_summary_format_string
.format("Total releases : ", nddr
.nddr_refrele_cnt
)
1190 while (cnt
< NDDR_TRACE_HIST_SIZE
):
1192 while (ix
< CTRACE_STACK_SIZE
):
1193 kgm_pc
= nddr
.nddr_refhold
[cnt
].pc
[ix
]
1196 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(nddr
.nddr_refhold
[cnt
].th
) + "):\n"
1197 out_string
+= str(int(ix
+ 1)) + ": "
1198 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1203 while (cnt
< NDDR_TRACE_HIST_SIZE
):
1205 while (ix
< CTRACE_STACK_SIZE
):
1206 kgm_pc
= nddr
.nddr_refrele
[cnt
].pc
[ix
]
1209 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(nddr
.nddr_refrele
[cnt
].th
) + "):\n"
1210 out_string
+= str(int(ix
+ 1)) + ": "
1211 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1216 # EndMacro: nddr_showdbg
1218 # Macro: imo_showdbg
1219 @lldb_command('imo_showdbg')
1220 def IpmOptions(cmd_args
=None):
1221 """ Print the debug information of a ip_moptions structure
1223 if (cmd_args
== None or len(cmd_args
) == 0):
1224 print "Missing argument 0 in user function."
1228 imo
= kern
.GetValueFromAddress(cmd_args
[0], 'ip_moptions_dbg *')
1229 imo_summary_format_string
= "{0:s} {1:d}"
1230 out_string
+= imo_summary_format_string
.format("Total holds : ", imo
.imo_refhold_cnt
)
1231 out_string
+= imo_summary_format_string
.format("Total releases : ", imo
.imo_refrele_cnt
)
1233 while (cnt
< IMO_TRACE_HIST_SIZE
):
1235 while (ix
< CTRACE_STACK_SIZE
):
1236 kgm_pc
= imo
.imo_refhold
[cnt
].pc
[ix
]
1239 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(imo
.imo_refhold
[cnt
].th
) + "):\n"
1240 out_string
+= str(int(ix
+ 1)) + ": "
1241 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1246 while (cnt
< IMO_TRACE_HIST_SIZE
):
1248 while (ix
< CTRACE_STACK_SIZE
):
1249 kgm_pc
= imo
.imo_refrele
[cnt
].pc
[ix
]
1252 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(imo
.imo_refrele
[cnt
].th
) + "):\n"
1253 out_string
+= str(int(ix
+ 1)) + ": "
1254 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1259 # EndMacro: imo_showdbg
1261 # Macro: im6o_showdbg
1262 @lldb_command('im6o_showdbg')
1263 def IpmOptions(cmd_args
=None):
1264 """ Print the debug information of a ip6_moptions structure
1266 if (cmd_args
== None or len(cmd_args
) == 0):
1267 print "Missing argument 0 in user function."
1271 im6o
= kern
.GetValueFromAddress(cmd_args
[0], 'ip6_moptions_dbg *')
1272 im6o_summary_format_string
= "{0:s} {1:d}"
1273 out_string
+= im6o_summary_format_string
.format("Total holds : ", im6o
.im6o_refhold_cnt
)
1274 out_string
+= im6o_summary_format_string
.format("Total releases : ", im6o
.im6o_refrele_cnt
)
1276 while (cnt
< IM6O_TRACE_HIST_SIZE
):
1278 while (ix
< CTRACE_STACK_SIZE
):
1279 kgm_pc
= im6o
.im6o_refhold
[cnt
].pc
[ix
]
1282 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(im6o
.im6o_refhold
[cnt
].th
) + "):\n"
1283 out_string
+= str(int(ix
+ 1)) + ": "
1284 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1289 while (cnt
< IM6O_TRACE_HIST_SIZE
):
1291 while (ix
< CTRACE_STACK_SIZE
):
1292 kgm_pc
= im6o
.im6o_refrele
[cnt
].pc
[ix
]
1295 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(im6o
.im6o_refrele
[cnt
].th
) + "):\n"
1296 out_string
+= str(int(ix
+ 1)) + ": "
1297 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1302 # EndMacro: im6o_showdbg
1304 # Macro: rtentry_trash
1305 @lldb_command('rtentry_trash')
1306 def RtEntryTrash(cmd_args
=None):
1307 """ Walk the list of trash route entries
1310 rt_trash_head
= kern
.globals.rttrash_head
1311 rtd
= Cast(rt_trash_head
.tqh_first
, 'rtentry_dbg *')
1312 rt_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1314 while (int(rtd
) != 0):
1316 if (kern
.ptrsize
== 8):
1317 print " rtentry ref hold rele dst gw parent flags/if\n"
1318 print " ----------------- --- ------ ------ --------------- ----- ------------------ -----------\n"
1320 print " rtentry ref hold rele dst gw parent flags/if\n"
1321 print " --------- --- ------ ------ --------------- ----- ---------- -----------\n"
1322 out_string
+= rt_trash_format_string
.format(cnt
, rtd
, rtd
.rtd_refhold_cnt
- rtd
.rtd_refrele_cnt
, rtd
.rtd_refhold_cnt
, rtd
.rtd_refrele_cnt
) + " "
1323 out_string
+= GetRtEntryPrDetailsAsString(rtd
) + "\n"
1324 rtd
= rtd
.rtd_trash_link
.tqe_next
1327 # EndMacro: rtentry_trash
1329 # Macro: inifa_trash
1330 @lldb_command('inifa_trash')
1331 def InIfaTrash(cmd_args
=None):
1332 """ Walk the list of trash in_ifaddr entries
1335 ifa_trash_head
= kern
.globals.inifa_trash_head
1336 ifa
= Cast(ifa_trash_head
.tqh_first
, 'in_ifaddr_dbg *')
1337 inifa_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1339 while (int(ifa
) != 0):
1341 if (kern
.ptrsize
== 8):
1342 print " in_ifa ref hold rele"
1343 print " ------------------ --- ------ ----"
1345 print " in_ifa ref hold rele"
1346 print " ---------- --- ----- ------"
1347 out_string
+= inifa_trash_format_string
.format(cnt
+ 1, ifa
, ifa
.inifa_refhold_cnt
- ifa
.inifa_refrele_cnt
, ifa
.inifa_refhold_cnt
, ifa
.inifa_refrele_cnt
) + " "
1348 out_string
+= GetSocketAddrAsStringInet(ifa
.inifa
.ia_ifa
.ifa_addr
) + "\n"
1349 ifa
= ifa
.inifa_trash_link
.tqe_next
1352 # EndMacro: inifa_trash
1354 # Macro: in6ifa_trash
1355 @lldb_command('in6ifa_trash')
1356 def In6IfaTrash(cmd_args
=None):
1357 """ Walk the list of trash in6_ifaddr entries
1360 in6ifa_trash_head
= kern
.globals.in6ifa_trash_head
1361 ifa
= Cast(in6ifa_trash_head
.tqh_first
, 'in6_ifaddr_dbg *')
1362 in6ifa_trash_format_string
= "{0:4d}: 0x{1:x} {2:3d} {3:6d} {4:6d}"
1364 while (int(ifa
) != 0):
1366 if (kern
.ptrsize
== 8):
1367 print " in6_ifa ref hold rele"
1368 print " ------------------ --- ------ ------"
1370 print " in6_ifa ref hold rele"
1371 print " ---------- --- ------ ------"
1372 out_string
+= in6ifa_trash_format_string
.format(cnt
+ 1, ifa
, ifa
.in6ifa_refhold_cnt
- ifa
.in6ifa_refrele_cnt
, ifa
.in6ifa_refhold_cnt
, ifa
.in6ifa_refrele_cnt
) + " "
1373 out_string
+= GetSocketAddrAsStringInet6(ifa
.in6ifa
.ia_ifa
.ifa_addr
) + "\n"
1374 ifa
= ifa
.in6ifa_trash_link
.tqe_next
1377 # EndMacro: in6ifa_trash
1380 @lldb_command('inm_trash')
1381 def InmTrash(cmd_args
=None):
1382 """ Walk the list of trash in_multi entries
1385 inm_trash_head
= kern
.globals.inm_trash_head
1386 inm
= Cast(inm_trash_head
.tqh_first
, 'in_multi_dbg *')
1387 inm_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1389 while (int(inm
) != 0):
1391 if (kern
.ptrsize
== 8):
1392 print " inm ref hold rele"
1393 print " ------------------ --- ------ ------"
1395 print " inm ref hold rele"
1396 print " ---------- --- ------ ------"
1397 out_string
+= inm_trash_format_string
.format(cnt
+ 1, inm
, inm
.inm_refhold_cnt
- inm
.inm_refrele_cnt
, inm
.inm_refhold_cnt
, inm
.inm_refrele_cnt
) + " "
1398 out_string
+= GetInAddrAsString(addressof(inm
.inm
.inm_addr
)) + "\n"
1399 inm
= inm
.inm_trash_link
.tqe_next
1402 # EndMacro: inm_trash
1405 @lldb_command('in6m_trash')
1406 def In6mTrash(cmd_args
=None):
1407 """ Walk the list of trash in6_multi entries
1410 in6m_trash_head
= kern
.globals.in6m_trash_head
1411 in6m
= Cast(in6m_trash_head
.tqh_first
, 'in6_multi_dbg *')
1412 in6m_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1414 while (int(in6m
) != 0):
1416 if (kern
.ptrsize
== 8):
1417 print " in6m ref hold rele"
1418 print " ------------------ --- ------ ------"
1420 print " in6m ref hold rele"
1421 print " ---------- --- ------ ------"
1422 out_string
+= in6m_trash_format_string
.format(cnt
+ 1, in6m
, in6m
.in6m_refhold_cnt
- in6m
.in6m_refrele_cnt
, in6m
.in6m_refhold_cnt
, in6m
.in6m_refrele_cnt
) + " "
1423 out_string
+= GetIn6AddrAsString(addressof(in6m
.in6m
.in6m_addr
)) + "\n"
1424 in6m
= in6m
.in6m_trash_link
.tqe_next
1427 # EndMacro: in6m_trash
1430 @lldb_command('ifma_trash')
1431 def IfmaTrash(cmd_args
=None):
1432 """ Walk the list of trash ifmultiaddr entries
1435 ifma_trash_head
= kern
.globals.ifma_trash_head
1436 ifma
= Cast(ifma_trash_head
.tqh_first
, 'ifmultiaddr_dbg *')
1437 ifma_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1439 while (int(ifma
) != 0):
1441 if (kern
.ptrsize
== 8):
1442 print " ifma ref hold rele"
1443 print " ------------------ --- ------ ------"
1445 print " ifma ref hold rele"
1446 print " ---------- --- ------ ------"
1447 out_string
+= ifma_trash_format_string
.format(cnt
+ 1, ifma
, ifma
.ifma_refhold_cnt
- ifma
.ifma_refrele_cnt
, ifma
.ifma_refhold_cnt
, ifma
.ifma_refrele_cnt
) + " "
1448 out_string
+= GetSocketAddrAsString(ifma
.ifma
.ifma_addr
) + "\n"
1449 out_string
+= " @ " + ifma
.ifma
.ifma_ifp
.if_xname
1450 ifma
= ifma
.ifma_trash_link
.tqe_next
1453 # EndMacro: ifma_trash
1455 def GetInPcb(pcb
, proto
):
1457 out_string
+= hex(pcb
)
1459 if (proto
== IPPROTO_TCP
):
1460 out_string
+= " tcp"
1462 if (proto
== IPPROTO_UDP
):
1463 out_string
+= " udp"
1465 out_string
+= str(proto
) + "."
1466 if (pcb
.inp_vflag
& INP_IPV4
):
1468 if (pcb
.inp_vflag
& INP_IPV6
):
1471 if (pcb
.inp_vflag
& INP_IPV4
):
1473 out_string
+= GetInAddrAsString(addressof(pcb
.inp_dependladdr
.inp46_local
.ia46_addr4
))
1475 out_string
+= GetIn6AddrAsString((pcb
.inp_dependladdr
.inp6_local
.__u6_addr
.__u6_addr
8))
1478 out_string
+= Getntohs(pcb
.inp_lport
)
1481 if (pcb
.inp_vflag
& INP_IPV4
):
1483 out_string
+= GetInAddrAsString(addressof(pcb
.inp_dependfaddr
.inp46_foreign
.ia46_addr4
))
1485 out_string
+= GetIn6AddrAsString((pcb
.inp_dependfaddr
.inp6_foreign
.__u6_addr
.__u6_addr
8))
1488 out_string
+= Getntohs(pcb
.inp_fport
)
1491 if (proto
== IPPROTO_TCP
):
1492 out_string
+= GetTcpState(pcb
.inp_ppcb
)
1494 if (pcb
.inp_flags
& INP_RECVOPTS
):
1495 out_string
+= "recvopts "
1496 if (pcb
.inp_flags
& INP_RECVRETOPTS
):
1497 out_string
+= "recvretopts "
1498 if (pcb
.inp_flags
& INP_RECVDSTADDR
):
1499 out_string
+= "recvdstaddr "
1500 if (pcb
.inp_flags
& INP_HDRINCL
):
1501 out_string
+= "hdrincl "
1502 if (pcb
.inp_flags
& INP_HIGHPORT
):
1503 out_string
+= "highport "
1504 if (pcb
.inp_flags
& INP_LOWPORT
):
1505 out_string
+= "lowport "
1506 if (pcb
.inp_flags
& INP_ANONPORT
):
1507 out_string
+= "anonport "
1508 if (pcb
.inp_flags
& INP_RECVIF
):
1509 out_string
+= "recvif "
1510 if (pcb
.inp_flags
& INP_MTUDISC
):
1511 out_string
+= "mtudisc "
1512 if (pcb
.inp_flags
& INP_STRIPHDR
):
1513 out_string
+= "striphdr "
1514 if (pcb
.inp_flags
& INP_RECV_ANYIF
):
1515 out_string
+= "recv_anyif "
1516 if (pcb
.inp_flags
& INP_INADDR_ANY
):
1517 out_string
+= "inaddr_any "
1518 if (pcb
.inp_flags
& INP_RECVTTL
):
1519 out_string
+= "recvttl "
1520 if (pcb
.inp_flags
& INP_UDP_NOCKSUM
):
1521 out_string
+= "nocksum "
1522 if (pcb
.inp_flags
& INP_BOUND_IF
):
1523 out_string
+= "boundif "
1524 if (pcb
.inp_flags
& IN6P_IPV6_V6ONLY
):
1525 out_string
+= "v6only "
1526 if (pcb
.inp_flags
& IN6P_PKTINFO
):
1527 out_string
+= "pktinfo "
1528 if (pcb
.inp_flags
& IN6P_HOPLIMIT
):
1529 out_string
+= "hoplimit "
1530 if (pcb
.inp_flags
& IN6P_HOPOPTS
):
1531 out_string
+= "hopopts "
1532 if (pcb
.inp_flags
& IN6P_DSTOPTS
):
1533 out_string
+= "dstopts "
1534 if (pcb
.inp_flags
& IN6P_RTHDR
):
1535 out_string
+= "rthdr "
1536 if (pcb
.inp_flags
& IN6P_RTHDRDSTOPTS
):
1537 out_string
+= "rthdrdstopts "
1538 if (pcb
.inp_flags
& IN6P_TCLASS
):
1539 out_string
+= "rcv_tclass "
1540 if (pcb
.inp_flags
& IN6P_AUTOFLOWLABEL
):
1541 out_string
+= "autoflowlabel "
1542 if (pcb
.inp_flags
& IN6P_BINDV6ONLY
):
1543 out_string
+= "bindv6only "
1544 if (pcb
.inp_flags
& IN6P_RFC2292
):
1545 out_string
+= "RFC2292 "
1546 if (pcb
.inp_flags
& IN6P_MTU
):
1547 out_string
+= "rcv_pmtu "
1548 if (pcb
.inp_flags
& INP_PKTINFO
):
1549 out_string
+= "pktinfo "
1550 if (pcb
.inp_flags
& INP_FLOW_SUSPENDED
):
1551 out_string
+= "suspended "
1552 if (pcb
.inp_flags
& INP_NO_IFT_CELLULAR
):
1553 out_string
+= "nocellular "
1554 if (pcb
.inp_flags
& INP_FLOW_CONTROLLED
):
1555 out_string
+= "flowctld "
1556 if (pcb
.inp_flags
& INP_FC_FEEDBACK
):
1557 out_string
+= "fcfeedback "
1558 if (pcb
.inp_flags2
& INP2_TIMEWAIT
):
1559 out_string
+= "timewait "
1560 if (pcb
.inp_flags2
& INP2_IN_FCTREE
):
1561 out_string
+= "in_fctree "
1562 if (pcb
.inp_flags2
& INP2_WANT_APP_POLICY
):
1563 out_string
+= "want_app_policy "
1567 out_string
+= "[so=" + str(so
) + " s=" + str(int(so
.so_snd
.sb_cc
)) + " r=" + str(int(so
.so_rcv
.sb_cc
)) + " usecnt=" + str(int(so
.so_usecount
)) + "] "
1569 if (pcb
.inp_state
== 0 or pcb
.inp_state
== INPCB_STATE_INUSE
):
1570 out_string
+= "inuse, "
1572 if (pcb
.inp_state
== INPCB_STATE_DEAD
):
1573 out_string
+= "dead, "
1575 out_string
+= "unknown (" + str(int(pcb
.inp_state
)) + "), "
1579 def GetPcbInfo(pcbi
, proto
):
1582 snd_buf
= unsigned(0)
1584 rcv_buf
= unsigned(0)
1586 out_string
+= "lastport " + str(int(pcbi
.ipi_lastport
)) + " lastlow " + str(int(pcbi
.ipi_lastlow
)) + " lasthi " + str(int(pcbi
.ipi_lasthi
)) + "\n"
1587 out_string
+= "active pcb count is " + str(int(pcbi
.ipi_count
)) + "\n"
1588 hashsize
= pcbi
.ipi_hashmask
+ 1
1589 out_string
+= "hash size is " + str(int(hashsize
)) + "\n"
1590 out_string
+= str(pcbi
.ipi_hashbase
) + " has the following inpcb(s):\n"
1591 if (kern
.ptrsize
== 8):
1592 out_string
+= "pcb proto source address port destination address port\n"
1594 out_string
+= "pcb proto source address port destination address port\n\n"
1597 hashbase
= pcbi
.ipi_hashbase
1598 while (i
< hashsize
):
1600 pcb
= cast(head
.lh_first
, 'inpcb *')
1603 out_string
+= GetInPcb(pcb
, proto
) + "\n"
1606 snd_cc
+= so
.so_snd
.sb_cc
1607 mp
= so
.so_snd
.sb_mb
1610 if (mp
.m_hdr
.mh_flags
& 0x01):
1611 snd_buf
= mp
.M_dat
.MH
.MH_dat
.MH_ext
.ext_size
1612 mp
= mp
.m_hdr
.mh_next
1613 rcv_cc
+= so
.so_rcv
.sb_cc
1614 mp
= so
.so_rcv
.sb_mb
1617 if (mp
.m_hdr
.mh_flags
& 0x01):
1618 rcv_buf
+= mp
.M_dat
.MH
.MH_dat
.MH_ext
.ext_size
1619 mp
= mp
.m_hdr
.mh_next
1620 pcb
= cast(pcb
.inp_hash
.le_next
, 'inpcb *')
1623 out_string
+= "total seen " + str(int(pcbseen
)) + " snd_cc " + str(int(snd_cc
)) + " rcv_cc " + str(int(rcv_cc
)) + "\n"
1624 out_string
+= "total snd_buf " + str(int(snd_buf
)) + " rcv_buf " + str(int(rcv_buf
)) + "\n"
1625 out_string
+= "port hash base is " + hex(pcbi
.ipi_porthashbase
) + "\n"
1628 hashbase
= pcbi
.ipi_porthashbase
1629 while (i
< hashsize
):
1631 pcb
= cast(head
.lh_first
, 'inpcbport *')
1634 out_string
+= GetInPcbPort(pcb
)
1636 pcb
= cast(pcb
.phd_hash
.le_next
, 'inpcbport *')
1641 def GetInPcbPort(ppcb
):
1643 out_string
+= hex(ppcb
) + ": lport "
1644 out_string
+= Getntohs(ppcb
.phd_port
)
1650 #p = unsigned(int(port) & 0x0000ffff)
1651 p
= ((port
& 0x0000ff00) >> 8)
1652 p |
= ((port
& 0x000000ff) << 8)
1655 # Macro: show_kern_event_pcbinfo
1656 def GetKernEventPcbInfo(kev_pcb_head
):
1658 pcb
= Cast(kev_pcb_head
.lh_first
, 'kern_event_pcb *')
1659 if (kern
.ptrsize
== 8):
1660 kev_pcb_format_string
= "0x{0:<16x} {1:12d} {2:16d} {3:16d}"
1661 out_string
+= " evp socket vendor code class filter subclass filter\n"
1662 out_string
+= "-------------- ----------- ------------ ---------------\n"
1664 kev_pcb_format_string
= "0x{0:<8x} {1:12d} {2:16d} {3:16d}"
1665 out_string
+= "evp socket vendor code class filter subclass filter\n"
1666 out_string
+= "---------- ----------- ------------ ---------------\n"
1668 out_string
+= kev_pcb_format_string
.format(pcb
.evp_socket
, pcb
.evp_vendor_code_filter
, pcb
.evp_class_filter
, pcb
.evp_subclass_filter
)
1670 pcb
= pcb
.evp_link
.le_next
1673 @lldb_command('show_kern_event_pcbinfo')
1674 def ShowKernEventPcbInfo(cmd_args
=None):
1675 """ Display the list of Kernel Event protocol control block information
1677 print GetKernEventPcbInfo(addressof(kern
.globals.kern_event_head
))
1678 # EndMacro: show_kern_event_pcbinfo
1680 # Macro: show_kern_control_pcbinfo
1681 def GetKernControlPcbInfo(ctl_head
):
1683 kctl
= Cast(ctl_head
.tqh_first
, 'kctl *')
1684 if (kern
.ptrsize
== 8):
1685 kcb_format_string
= "0x{0:<16x} {1:4d} {2:10d}\n"
1687 kcb_format_string
= "0x{0:<8x} {1:4d} {2:10d}\n"
1688 while unsigned(kctl
) != 0:
1689 kctl_name
= "controller: " + str(kctl
.name
) + "\n"
1690 out_string
+= kctl_name
1691 kcb
= Cast(kctl
.kcb_head
.tqh_first
, 'ctl_cb *')
1692 if unsigned(kcb
) != 0:
1693 if (kern
.ptrsize
== 8):
1694 out_string
+= "socket unit usecount\n"
1695 out_string
+= "------ ---- --------\n"
1697 out_string
+= "socket unit usecount\n"
1698 out_string
+= "------ ---- --------\n"
1699 while unsigned(kcb
) != 0:
1700 out_string
+= kcb_format_string
.format(kcb
.so
, kcb
.unit
, kcb
.usecount
)
1701 kcb
= kcb
.next
.tqe_next
1703 kctl
= kctl
.next
.tqe_next
1706 @lldb_command('show_kern_control_pcbinfo')
1707 def ShowKernControlPcbInfo(cmd_args
=None):
1708 """ Display the list of Kernel Control protocol control block information
1710 print GetKernControlPcbInfo(addressof(kern
.globals.ctl_head
))
1711 # EndMacro: show_kern_control_pcbinfo
1713 # Macro: show_tcp_pcbinfo
1714 @lldb_command('show_tcp_pcbinfo')
1715 def ShowTcpPcbInfo(cmd_args
=None):
1716 """ Display the list of TCP protocol control block information
1718 print GetPcbInfo(addressof(kern
.globals.tcbinfo
), IPPROTO_TCP
)
1719 # EndMacro: show_tcp_pcbinfo
1721 # Macro: show_udp_pcbinfo
1722 @lldb_command('show_udp_pcbinfo')
1723 def ShowUdpPcbInfo(cmd_args
=None):
1724 """ Display the list of UDP protocol control block information
1726 print GetPcbInfo(addressof(kern
.globals.udbinfo
), IPPROTO_UDP
)
1727 # EndMacro: show_udp_pcbinfo
1729 # Macro: show_tcp_timewaitslots
1730 @lldb_command('show_tcp_timewaitslots')
1731 def ShowTcpTimeWaitSlots(cmd_args
=None):
1732 """ Display the list of the TCP protocol control blocks in TIMEWAIT
1738 if len(cmd_args
) > 0:
1739 if (int(cmd_args
[0]) == -1):
1742 slot
= int(cmd_args
[0])
1744 out_string
+= "time wait slot size " + str(N_TIME_WAIT_SLOTS
) + " cur_tw_slot " + str(int(kern
.globals.cur_tw_slot
)) + "\n"
1747 while (i
< N_TIME_WAIT_SLOTS
):
1749 head
= kern
.globals.time_wait_slots
[i
]
1750 if (i
== slot
or slot
== -1):
1751 pcb0
= cast(head
.lh_first
, 'inpcb *')
1754 pcb0
= pcb0
.inp_list
.le_next
1756 out_string
+= " slot " + str(i
) + " count " + str(perslot
) + "\n"
1758 if (_all
or i
== slot
):
1759 pcb0
= cast(head
.lh_first
, 'inpcb *')
1762 out_string
+= GetInPcb(pcb0
, IPPROTO_TCP
)
1764 pcb0
= pcb0
.inp_list
.le_next
1768 # EndMacro: show_tcp_timewaitslots
1770 # Macro: show_domains
1771 @lldb_command('show_domains')
1772 def ShowDomains(cmd_args
=None):
1773 """ Display the list of the domains
1776 domains
= kern
.globals.domains
1777 dp
= Cast(domains
.tqh_first
, 'domain *')
1778 ifma_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1781 out_string
+= "\"" + str(dp
.dom_name
) + "\"" + "[" + str(int(dp
.dom_refs
)) + " refs] domain " + hex(dp
) + "\n"
1782 out_string
+= " family:\t" + str(int(dp
.dom_family
)) + "\n"
1783 out_string
+= " flags:0x\t" + str(int(dp
.dom_flags
)) + "\n"
1784 out_string
+= " rtparams:\toff=" + str(int(dp
.dom_rtoffset
)) + ", maxrtkey=" + str(int(dp
.dom_maxrtkey
)) + "\n"
1787 out_string
+= " init:\t"
1788 out_string
+= GetSourceInformationForAddress(dp
.dom_init
) + "\n"
1789 if (dp
.dom_externalize
):
1790 out_string
+= " externalize:\t"
1791 out_string
+= GetSourceInformationForAddress(dp
.dom_externalize
) + "\n"
1792 if (dp
.dom_dispose
):
1793 out_string
+= " dispose:\t"
1794 out_string
+= GetSourceInformationForAddress(dp
.dom_dispose
) + "\n"
1795 if (dp
.dom_rtattach
):
1796 out_string
+= " rtattach:\t"
1797 out_string
+= GetSourceInformationForAddress(dp
.dom_rtattach
) + "\n"
1799 out_string
+= " old:\t"
1800 out_string
+= GetSourceInformationForAddress(dp
.dom_old
) + "\n"
1802 pr
= Cast(dp
.dom_protosw
.tqh_first
, 'protosw *')
1805 out_string
+= "\ttype " + str(int(pr
.pr_type
)) + ", protocol " + str(int(pr
.pr_protocol
)) + ", protosw " + hex(pr
) + "\n"
1806 out_string
+= "\t flags:0x\t" + hex(pr
.pr_flags
) + "\n"
1808 out_string
+= "\t input:\t"
1809 out_string
+= GetSourceInformationForAddress(pr
.pr_input
) + "\n"
1811 out_string
+= "\t output:\t"
1812 out_string
+= GetSourceInformationForAddress(pr
.pr_output
) + "\n"
1813 if (pr
.pr_ctlinput
):
1814 out_string
+= "\t ctlinput:\t"
1815 out_string
+= GetSourceInformationForAddress(pr
.pr_ctlinput
) + "\n"
1816 if (pr
.pr_ctloutput
):
1817 out_string
+= "\t ctloutput:\t"
1818 out_string
+= GetSourceInformationForAddress(pr
.pr_ctloutput
) + "\n"
1820 out_string
+= "\t init:\t"
1821 out_string
+= GetSourceInformationForAddress(pr
.pr_init
) + "\n"
1823 out_string
+= "\t drain:\t"
1824 out_string
+= GetSourceInformationForAddress(pr
.pr_drain
) + "\n"
1826 out_string
+= "\t sysctl:\t"
1827 out_string
+= GetSourceInformationForAddress(pr
.pr_sysctl
) + "\n"
1829 out_string
+= "\t lock:\t"
1830 out_string
+= GetSourceInformationForAddress(pr
.pr_lock
) + "\n"
1832 out_string
+= "\t unlock:\t"
1833 out_string
+= GetSourceInformationForAddress(pr
.pr_unlock
) + "\n"
1835 out_string
+= "\t getlock:\t"
1836 out_string
+= GetSourceInformationForAddress(pr
.pr_getlock
) + "\n"
1838 out_string
+= "\t old:\t"
1839 out_string
+= GetSourceInformationForAddress(pr
.pr_old
) + "\n"
1841 out_string
+= "\t pru_flags:0x\t" + hex(pru
.pru_flags
) + "\n"
1842 out_string
+= "\t abort:\t"
1843 out_string
+= GetSourceInformationForAddress(pru
.pru_abort
) + "\n"
1844 out_string
+= "\t accept:\t"
1845 out_string
+= GetSourceInformationForAddress(pru
.pru_accept
) + "\n"
1846 out_string
+= "\t attach:\t"
1847 out_string
+= GetSourceInformationForAddress(pru
.pru_attach
) + "\n"
1848 out_string
+= "\t bind:\t"
1849 out_string
+= GetSourceInformationForAddress(pru
.pru_bind
) + "\n"
1850 out_string
+= "\t connect:\t"
1851 out_string
+= GetSourceInformationForAddress(pru
.pru_connect
) + "\n"
1852 out_string
+= "\t connect2:\t"
1853 out_string
+= GetSourceInformationForAddress(pru
.pru_connect2
) + "\n"
1854 out_string
+= "\t connectx:\t"
1855 out_string
+= GetSourceInformationForAddress(pru
.pru_connectx
) + "\n"
1856 out_string
+= "\t control:\t"
1857 out_string
+= GetSourceInformationForAddress(pru
.pru_control
) + "\n"
1858 out_string
+= "\t detach:\t"
1859 out_string
+= GetSourceInformationForAddress(pru
.pru_detach
) + "\n"
1860 out_string
+= "\t disconnect:\t"
1861 out_string
+= GetSourceInformationForAddress(pru
.pru_disconnect
) + "\n"
1862 out_string
+= "\t listen:\t"
1863 out_string
+= GetSourceInformationForAddress(pru
.pru_listen
) + "\n"
1864 out_string
+= "\t peeloff:\t"
1865 out_string
+= GetSourceInformationForAddress(pru
.pru_peeloff
) + "\n"
1866 out_string
+= "\t peeraddr:\t"
1867 out_string
+= GetSourceInformationForAddress(pru
.pru_peeraddr
) + "\n"
1868 out_string
+= "\t rcvd:\t"
1869 out_string
+= GetSourceInformationForAddress(pru
.pru_rcvd
) + "\n"
1870 out_string
+= "\t rcvoob:\t"
1871 out_string
+= GetSourceInformationForAddress(pru
.pru_rcvoob
) + "\n"
1872 out_string
+= "\t send:\t"
1873 out_string
+= GetSourceInformationForAddress(pru
.pru_send
) + "\n"
1874 out_string
+= "\t sense:\t"
1875 out_string
+= GetSourceInformationForAddress(pru
.pru_sense
) + "\n"
1876 out_string
+= "\t shutdown:\t"
1877 out_string
+= GetSourceInformationForAddress(pru
.pru_shutdown
) + "\n"
1878 out_string
+= "\t sockaddr:\t"
1879 out_string
+= GetSourceInformationForAddress(pru
.pru_sockaddr
) + "\n"
1880 out_string
+= "\t sopoll:\t"
1881 out_string
+= GetSourceInformationForAddress(pru
.pru_sopoll
) + "\n"
1882 out_string
+= "\t soreceive:\t"
1883 out_string
+= GetSourceInformationForAddress(pru
.pru_soreceive
) + "\n"
1884 out_string
+= "\t sosend:\t"
1885 out_string
+= GetSourceInformationForAddress(pru
.pru_sosend
) + "\n"
1886 pr
= pr
.pr_entry
.tqe_next
1887 dp
= dp
.dom_entry
.tqe_next
1890 # EndMacro: show_domains