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 *')
34 dlifnet
= Cast(ifnet
, 'dlil_ifnet *')
36 format_string
= "{0: <s}: flags={1: <x} <{2: <s}> index {3: <d} mtu {4: <d}"
38 out_string
+= format_string
.format(iface
.if_xname
, (iface
.if_flags
& 0xffff), GetIfFlagsAsString(iface
.if_flags
), iface
.if_index
, iface
.if_data
.ifi_mtu
)
39 out_string
+= "\n\t(struct ifnet *)" + hex(ifnet
)
40 if iface
.if_snd
.ifcq_len
:
41 out_string
+= "\n\t" + str(iface
.if_snd
.ifcq_len
)
42 if dlifnet
.dl_if_inpstorage
.rcvq_pkts
.qlen
:
43 out_string
+= "\n\t" + str(dlifnet
.dl_if_inpstorage
.rcvq_pkts
.qlen
)
46 def GetIfConfiguration(ifname
):
47 """ Return ifnet structure corresponding to the ifname passed in
50 ifnets
= kern
.globals.ifnet_head
51 for ifnet
in IterateTAILQ_HEAD(ifnets
, "if_link") :
52 if str(ifnet
.if_xname
) == ifname
:
57 @lldb_command('ifconfig')
58 def ShowIfconfig(cmd_args
=None) :
59 """ Display ifconfig-like output, and print the (struct ifnet *) pointers for further inspection
61 if cmd_args
!= None and len(cmd_args
) > 0:
66 ifnets
= kern
.globals.ifnet_head
67 for ifnet
in IterateTAILQ_HEAD(ifnets
, "if_link"):
68 ShowIfConfiguration(ifnet
)
70 print GetIfaddrs(ifnet
)
73 def GetAddressAsStringColonHex(addr
, count
):
76 addr_format_string
= "{0:02x}"
79 out_string
+= addr_format_string
.format(addr
[i
])[-2:]
81 out_string
+= ":" + addr_format_string
.format(addr
[i
])[-2:]
85 def GetSocketAddrAsStringUnspec(sockaddr
):
87 out_string
+= GetAddressAsStringColonHex(sockaddr
.sa_data
, sockaddr
.sa_len
- 2)
90 def GetSocketAddrAsStringUnix(sockaddr
):
91 sock_unix
= Cast(sockaddr
, 'sockaddr_un *')
95 if (len(str(sock_unix
.sun_path
)) > 0):
96 return str(sock_unix
.sun_path
)
100 def GetInAddrAsString(ia
):
102 inaddr
= Cast(ia
, 'in_addr *')
104 packed_value
= struct
.pack('I', unsigned(ia
.s_addr
))
105 out_string
= inet_ntoa(packed_value
)
108 def GetIn6AddrAsString(ia
):
112 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}"
113 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]))
116 def GetSocketAddrAsStringInet(sockaddr
):
117 sock_in
= Cast(sockaddr
, 'sockaddr_in *')
118 return GetInAddrAsString(sock_in
.sin_addr
)
120 def GetSocketAddrAsStringInet6(sockaddr
):
121 sock_in6
= Cast(sockaddr
, 'sockaddr_in6 *')
122 return GetIn6AddrAsString(sock_in6
.sin6_addr
.__u6_addr
.__u6_addr
8)
124 def GetSocketAddrAsStringLink(sockaddr
):
125 sock_link
= Cast(sockaddr
, 'sockaddr_dl *')
126 if sock_link
is None:
130 if (sock_link
.sdl_nlen
== 0 and sock_link
.sdl_alen
== 0 and sock_link
.sdl_slen
== 0):
131 out_string
= "link#" + str(int(sock_link
.sdl_index
))
133 out_string
+= GetAddressAsStringColonHex(addressof(sock_link
.sdl_data
[sock_link
.sdl_nlen
]), sock_link
.sdl_alen
)
136 def GetSocketAddrAsStringAT(sockaddr
):
138 sock_addr
= Cast(sockaddr
, 'sockaddr *')
139 out_string
+= GetAddressAsStringColonHex(sockaddr
.sa_data
, sockaddr
.sa_len
- 2)
142 def GetSocketAddrAsString(sockaddr
):
143 if sockaddr
is None :
146 if (sockaddr
.sa_family
== 0):
147 out_string
+= "UNSPC "
148 GetSocketAddrAsStringUnspec(sockaddr
)
149 elif (sockaddr
.sa_family
== 1):
150 out_string
+= "UNIX "
151 out_string
+= GetSocketAddrAsStringUnix(sockaddr
)
152 elif (sockaddr
.sa_family
== 2):
153 out_string
+= "INET "
154 out_string
+= GetSocketAddrAsStringInet(sockaddr
)
155 elif (sockaddr
.sa_family
== 30):
156 out_string
+= "INET6 "
157 out_string
+= GetSocketAddrAsStringInet6(sockaddr
)
158 elif (sockaddr
.sa_family
== 18):
159 out_string
+= "LINK "
160 out_string
+= GetSocketAddrAsStringLink(sockaddr
)
161 elif (sockaddr
.sa_family
== 16):
162 out_string
+= "ATLK "
163 out_string
+= GetSocketAddrAsStringAT(sockaddr
)
165 out_string
+= "FAM " + str(sockaddr
.sa_family
)
166 out_string
+= GetAddressAsStringColonHex(sockaddr
.sa_data
, sockaddr
.sa_len
)
170 @lldb_command('showifaddrs')
171 def ShowIfaddrs(cmd_args
=None):
172 """ Show the (struct ifnet).if_addrhead list of addresses for the given ifp
174 if cmd_args
!= None and len(cmd_args
) > 0 :
175 ifp
= kern
.GetValueFromAddress(cmd_args
[0], 'ifnet *')
177 print "Unknown value passed as argument."
180 for ifaddr
in IterateTAILQ_HEAD(ifp
.if_addrhead
, "ifa_link"):
181 format_string
= "\t{0: <d}: 0x{1: <x} {2: <s} [{3: <d}]"
182 print format_string
.format(i
, ifaddr
, GetSocketAddrAsString(ifaddr
.ifa_addr
), ifaddr
.ifa_refcnt
)
185 print "Missing argument 0 in user function."
186 # EndMacro: showifaddrs
192 for ifaddr
in IterateTAILQ_HEAD(ifp
.if_addrhead
, "ifa_link"):
193 format_string
= "\t{0: <d}: 0x{1: <x} {2: <s} [{3: <d}]"
194 out_string
+= format_string
.format(i
, ifaddr
, GetSocketAddrAsString(ifaddr
.ifa_addr
), ifaddr
.ifa_refcnt
) + "\n"
197 out_string
+= "Missing argument 0 in user function."
201 def GetCapabilitiesAsString(flags
):
202 """ Return a formatted string description of the interface flags
209 out_string
+= if_capenable_strings
[i
] + ","
212 return rstrip(out_string
, ",")
214 def GetIfEflagsAsString(if_eflags
):
215 """ Return a formatted string description of the interface flags
218 flags
= unsigned(if_eflags
)
223 out_string
+= if_eflags_strings
[i
] + ","
226 return rstrip(out_string
, ",")
228 def ShowDlilIfnetConfiguration(dlil_ifnet
, show_all
) :
229 """ Formatted display of dlil_ifnet structures
234 if dlil_ifnet
is None :
237 dlil_iface
= Cast(dlil_ifnet
, 'dlil_ifnet *')
238 iface
= Cast(dlil_ifnet
, 'ifnet *')
240 if (dlil_iface
.dl_if_flags
& DLIF_REUSE
) :
242 format_string
= "{0: <s}: flags={1: <x} <{2: <s}> index {3: <d} mtu {4: <d}"
243 extended_flags_format_string
= "\n\teflags={0: <x} <{1: <s}>"
244 capenabled_format_string
= "\n\toptions={0: <x} <{1: <s}>"
245 if (dlil_iface
.dl_if_flags
& DLIF_INUSE
) :
246 out_string
+= format_string
.format(iface
.if_xname
, (iface
.if_flags
& 0xffff), GetIfFlagsAsString(iface
.if_flags
), iface
.if_index
, iface
.if_data
.ifi_mtu
)
248 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
)
249 if (iface
.if_eflags
) :
250 out_string
+= extended_flags_format_string
.format(iface
.if_eflags
, GetIfEflagsAsString(iface
.if_eflags
))
251 if (iface
.if_capenable
) :
252 out_string
+= capenabled_format_string
.format(iface
.if_capenable
, GetCapabilitiesAsString(iface
.if_capenable
))
253 out_string
+= "\n\t(struct ifnet *)" + hex(dlil_ifnet
) + "\n"
255 out_string
+= GetIfaddrs(iface
)
260 @lldb_command('showifnets')
261 def ShowIfnets(cmd_args
=None) :
262 """ Display ifconfig-like output for all attached and detached interfaces
265 if cmd_args
!= None and len(cmd_args
) > 0 :
267 dlil_ifnets
= kern
.globals.dlil_ifnet_head
268 for dlil_ifnet
in IterateTAILQ_HEAD(dlil_ifnets
, "dl_if_link"):
269 ShowDlilIfnetConfiguration(dlil_ifnet
, showall
)
270 # EndMacro: showifnets
272 # Macro: showifmultiaddrs
273 @lldb_command('showifmultiaddrs')
274 def ShowIfMultiAddrs(cmd_args
=None) :
275 """ Show the list of multicast addresses for the given ifp
278 if cmd_args
!= None and len(cmd_args
) > 0 :
279 ifp
= kern
.GetValueFromAddress(cmd_args
[0], 'ifnet *')
281 print "Unknown value passed as argument."
283 ifmulti
= cast(ifp
.if_multiaddrs
.lh_first
, 'ifmultiaddr *')
286 ifma_format_string
= "\t{0: <d}: 0x{1: <x} "
287 out_string
+= (ifma_format_string
.format(i
+ 1, ifmulti
))
288 if (ifmulti
.ifma_addr
.sa_family
== 2):
289 if (ifmulti
.ifma_ll
!= 0):
290 out_string
+= GetSocketAddrAsStringLink(ifmulti
.ifma_ll
.ifma_addr
) + " "
291 out_string
+= GetSocketAddrAsStringInet(ifmulti
.ifma_addr
)
292 if (ifmulti
.ifma_addr
.sa_family
== 30):
293 if (ifmulti
.ifma_ll
!= 0):
294 out_string
+= GetSocketAddrAsStringLink(ifmulti
.ifma_ll
.ifma_addr
) + " "
295 out_string
+= GetSocketAddrAsStringInet6(ifmulti
.ifma_addr
) + " "
296 if (ifmulti
.ifma_addr
.sa_family
== 18):
297 out_string
+= GetSocketAddrAsStringLink(ifmulti
.ifma_addr
) + " "
298 if (ifmulti
.ifma_addr
.sa_family
== 0):
299 out_string
+= GetSocketAddrAsStringUnspec(ifmulti
.ifma_addr
) + " "
300 out_string
+= "[" + str(int(ifmulti
.ifma_refcount
)) + "]\n"
301 ifmulti
= cast(ifmulti
.ifma_link
.le_next
, 'ifmultiaddr *')
305 print "Missing argument 0 in user function."
306 # EndMacro: showifmultiaddrs
308 # Macro: showinmultiaddrs
309 @lldb_command('showinmultiaddrs')
310 def ShowInMultiAddrs(cmd_args
=None) :
311 """ Show the contents of IPv4 multicast address records
314 inmultihead
= kern
.globals.in_multihead
315 inmulti
= cast(inmultihead
.lh_first
, 'in_multi *')
318 ifp
= inmulti
.inm_ifp
319 inma_format_string
= "\t{0: <d}: 0x{1: <x} "
320 out_string
+= inma_format_string
.format(i
+ 1, inmulti
) + " "
321 out_string
+= GetInAddrAsString(addressof(inmulti
.inm_addr
)) + " "
322 ifma_format_string
= "(ifp 0x{0: <x} [{1: <s}] ifma {2: <x})"
323 out_string
+= ifma_format_string
.format(ifp
, ifp
.if_xname
, inmulti
.inm_ifma
) + "\n"
324 inmulti
= cast(inmulti
.inm_link
.le_next
, 'in_multi *')
327 # EndMacro: showinmultiaddrs
329 # Macro: showin6multiaddrs
330 @lldb_command('showin6multiaddrs')
331 def ShowIn6MultiAddrs(cmd_args
=None) :
332 """ Show the contents of IPv6 multicast address records
335 in6multihead
= kern
.globals.in6_multihead
336 in6multi
= cast(in6multihead
.lh_first
, 'in6_multi *')
339 ifp
= in6multi
.in6m_ifp
340 inma_format_string
= "\t{0: <d}: 0x{1: <x} "
341 out_string
+= inma_format_string
.format(i
+ 1, in6multi
) + " "
342 out_string
+= GetIn6AddrAsString((in6multi
.in6m_addr
.__u6_addr
.__u6_addr
8)) + " "
343 ifma_format_string
= "(ifp 0x{0: <x} [{1: <s}] ifma {2: <x})"
344 out_string
+= ifma_format_string
.format(ifp
, ifp
.if_xname
, in6multi
.in6m_ifma
) + "\n"
345 in6multi
= cast(in6multi
.in6m_entry
.le_next
, 'in6_multi *')
348 # EndMacro: showin6multiaddrs
350 def GetTcpState(tcpcb
):
352 tp
= Cast(tcpcb
, 'tcpcb *')
355 out_string
+= "CLOSED\t"
357 out_string
+= "LISTEN\t"
359 out_string
+= "SYN_SENT\t"
361 out_string
+= "SYN_RCVD\t"
363 out_string
+= "ESTABLISHED\t"
365 out_string
+= "CLOSE_WAIT\t"
367 out_string
+= "FIN_WAIT_1\t"
369 out_string
+= "CLOSING\t"
371 out_string
+= "LAST_ACK\t"
373 out_string
+= "FIN_WAIT_2\t"
375 out_string
+= "TIME_WAIT\t"
378 def GetSocketProtocolAsString(sock
):
380 inpcb
= Cast(sock
.so_pcb
, 'inpcb *')
381 if sock
.so_proto
.pr_protocol
== 6:
382 out_string
+= " TCP "
383 out_string
+= GetTcpState(inpcb
.inp_ppcb
)
384 if sock
.so_proto
.pr_protocol
== 17:
385 out_string
+= " UDP "
386 if sock
.so_proto
.pr_protocol
== 1:
387 out_string
+= " ICMP "
388 if sock
.so_proto
.pr_protocol
== 254:
389 out_string
+= " DIVERT "
390 if sock
.so_proto
.pr_protocol
== 255:
391 out_string
+= " RAW "
394 def GetInAddr4to6AsString(inaddr
):
396 if (inaddr
is not None):
397 ia
= Cast(inaddr
, 'char *')
398 inaddr_format_string
= "{0: <d}.{1: <d}.{2: <d}.{3: <d}"
399 out_string
+= inaddr_format_string
.format(ia
[0], ia
[1], ia
[2], ia
[3])
402 def GetInPortAsString(port
):
404 port_string
= Cast(port
, 'char *')
405 port_unsigned
= dereference(Cast(port
, 'unsigned short *'))
407 if ((((port_unsigned
& 0xff00) >> 8) == port_string
[0])) and (((port_unsigned
& 0x00ff) == port_string
[1])):
408 out_string
+= ":" + str(int(port_unsigned
))
410 out_string
+= ":" + str(int(((port_unsigned
& 0xff00) >> 8) |
((port_unsigned
& 0x00ff) << 8)))
414 def GetIPv4SocketAsString(sock
) :
416 pcb
= Cast(sock
.so_pcb
, 'inpcb *')
418 out_string
+= "inpcb: (null) "
420 out_string
+= "inpcb: " + hex(pcb
)
421 out_string
+= GetSocketProtocolAsString(sock
)
423 out_string
+= GetInAddr4to6AsString(addressof(pcb
.inp_dependladdr
.inp46_local
))
424 out_string
+= GetInPortAsString(addressof(pcb
.inp_lport
))
426 out_string
+= GetInAddr4to6AsString(addressof(pcb
.inp_dependfaddr
.inp46_foreign
))
427 out_string
+= GetInPortAsString(addressof(pcb
.inp_fport
))
430 def GetIPv6SocketAsString(sock
) :
432 pcb
= Cast(sock
.so_pcb
, 'inpcb *')
434 out_string
+= "inpcb: (null) "
436 out_string
+= "inpcb: " + hex(pcb
) + " "
437 out_string
+= GetSocketProtocolAsString(sock
)
439 out_string
+= GetIn6AddrAsString((pcb
.inp_dependladdr
.inp6_local
.__u6_addr
.__u6_addr
8))
440 out_string
+= GetInPortAsString(addressof(pcb
.inp_lport
))
442 out_string
+= GetIn6AddrAsString((pcb
.inp_dependfaddr
.inp6_foreign
.__u6_addr
.__u6_addr
8))
443 out_string
+= GetInPortAsString(addressof(pcb
.inp_fport
))
446 def GetUnixDomainSocketAsString(sock
) :
448 pcb
= Cast(sock
.so_pcb
, 'unpcb *')
450 out_string
+= "unpcb: (null) "
452 out_string
+= "unpcb: " + hex(pcb
) + " "
453 out_string
+= "unp_vnode: " + hex(pcb
.unp_vnode
) + " "
454 out_string
+= "unp_conn: " + hex(pcb
.unp_conn
) + " "
455 out_string
+= "unp_addr: " + GetSocketAddrAsStringUnix(pcb
.unp_addr
)
458 def GetSocket(socket
) :
459 """ Show the contents of a socket
461 so
= kern
.GetValueFromAddress(unsigned(socket
), 'socket *')
464 sock_format_string
= "so: 0x{0:<x}"
465 out_string
+= sock_format_string
.format(so
)
466 domain
= so
.so_proto
.pr_domain
467 domain_name_format_string
= " {0:<s} "
468 out_string
+= domain_name_format_string
.format(domain
.dom_name
)
469 if (domain
.dom_family
== 1):
470 out_string
+= GetUnixDomainSocketAsString(so
)
471 if (domain
.dom_family
== 2):
472 out_string
+= GetIPv4SocketAsString(so
)
473 if (domain
.dom_family
== 30):
474 out_string
+= GetIPv6SocketAsString(so
)
476 out_string
+= "(null)"
478 # EndMacro: showsocket
482 @lldb_command('showsocket')
483 def ShowSocket(cmd_args
=None) :
484 """ Show the contents of a socket
486 if (cmd_args
== None or len(cmd_args
) == 0):
487 print "Missing argument 0 in user function."
489 so
= kern
.GetValueFromAddress(cmd_args
[0], 'socket *')
490 if (len(str(cmd_args
[0])) > 0):
492 sock_format_string
= "so: 0x{0:<x}"
493 out_string
+= sock_format_string
.format(so
)
494 domain
= so
.so_proto
.pr_domain
495 domain_name_format_string
= " {0:<s} "
496 out_string
+= domain_name_format_string
.format(domain
.dom_name
)
497 if (domain
.dom_family
== 1):
498 out_string
+= GetUnixDomainSocketAsString(so
)
499 if (domain
.dom_family
== 2):
500 out_string
+= GetIPv4SocketAsString(so
)
501 if (domain
.dom_family
== 30):
502 out_string
+= GetIPv6SocketAsString(so
)
505 print "Unknown value passed as argument."
507 # EndMacro: showsocket
509 # Macro: showprocsockets
510 @lldb_command('showprocsockets')
511 def ShowProcSockets(cmd_args
=None):
512 """ Given a proc_t pointer, display information about its sockets
516 if cmd_args
!= None and len(cmd_args
) > 0 :
517 proc
= kern
.GetValueFromAddress(cmd_args
[0], 'proc *')
521 print "Unknown value passed as argument."
525 fpp
= Cast(proc_fd
.fd_ofiles
, 'fileproc **')
526 while (count
< proc_fd
.fd_nfiles
):
527 fp
= Cast(dereference(fpp
), 'fileproc *')
529 fg
= Cast(fp
.f_fglob
, 'fileglob *')
530 if (int(fg
.fg_ops
.fo_type
) == 2):
531 if (proc_fd
.fd_ofileflags
[count
] & 4):
535 out_string
+= "fd = " + str(count
) + " "
536 if (fg
.fg_data
!= 0):
537 out_string
+= GetSocket(unsigned(fg
.fg_data
))
541 fpp
= kern
.GetValueFromAddress(unsigned(fpp
+ 8), 'fileproc **')
545 print "Missing argument 0 in user function."
546 # EndMacro: showprocsockets
548 def GetProcSockets(proc
):
549 """ Given a proc_t pointer, display information about its sockets
555 out_string
+= "Unknown value passed as argument."
558 fpp
= Cast(proc_fd
.fd_ofiles
, 'fileproc **')
559 while (count
< proc_fd
.fd_nfiles
):
560 fp
= Cast(dereference(fpp
), 'fileproc *')
562 fg
= Cast(fp
.f_fglob
, 'fileglob *')
563 if (int(fg
.fg_ops
.fo_type
) == 2):
564 if (proc_fd
.fd_ofileflags
[count
] & 4):
568 out_string
+= "fd = " + str(count
) + " "
569 if (fg
.fg_data
!= 0):
570 out_string
+= GetSocket(unsigned(fg
.fg_data
))
574 fpp
= kern
.GetValueFromAddress(unsigned(fpp
+ 8), 'fileproc **')
579 # Macro: showallprocsockets
580 @lldb_command('showallprocsockets')
581 def ShowAllProcSockets(cmd_args
=None):
582 """Display information about the sockets of all the processes
584 for proc
in kern
.procs
:
585 print "================================================================================"
586 print GetProcInfo(proc
)
587 print GetProcSockets(proc
)
588 # EndMacro: showallprocsockets
591 def GetRtEntryPrDetailsAsString(rte
):
593 rt
= Cast(rte
, 'rtentry *')
594 dst
= Cast(rt
.rt_nodes
[0].rn_u
.rn_leaf
.rn_Key
, 'sockaddr *')
596 dst_string_format
= "{0:<18s}"
597 if (dst
.sa_family
== AF_INET
):
598 out_string
+= dst_string_format
.format(GetSocketAddrAsStringInet(dst
)) + " "
600 if (dst
.sa_family
== AF_INET6
):
601 out_string
+= dst_string_format
.format(GetSocketAddrAsStringInet6(dst
)) + " "
604 if (dst
.sa_family
== AF_LINK
):
605 out_string
+= dst_string_format
.format(GetSocketAddrAsStringLink(dst
))
611 out_string
+= dst_string_format
.format(GetSocketAddrAsStringUnspec(dst
)) + " "
613 gw
= Cast(rt
.rt_gateway
, 'sockaddr *')
614 if (gw
.sa_family
== AF_INET
):
615 out_string
+= dst_string_format
.format(GetSocketAddrAsStringInet(gw
)) + " "
617 if (gw
.sa_family
== 30):
618 out_string
+= dst_string_format
.format(GetSocketAddrAsStringInet6(gw
)) + " "
621 if (gw
.sa_family
== 18):
622 out_string
+= dst_string_format
.format(GetSocketAddrAsStringLink(gw
)) + " "
628 dst_string_format
.format(GetSocketAddrAsStringUnspec(gw
))
630 if (rt
.rt_flags
& RTF_WASCLONED
):
631 if (kern
.ptrsize
== 8):
632 rt_flags_string_format
= "0x{0:<16x}"
633 out_string
+= rt_flags_string_format
.format(rt
.rt_parent
) + " "
635 rt_flags_string_format
= "0x{0:<8x}"
636 out_string
+= rt_flags_string_format
.format(rt
.rt_parent
) + " "
638 if (kern
.ptrsize
== 8):
643 rt_refcnt_rmx_string_format
= "{0:<d} {1:>10d} "
644 out_string
+= rt_refcnt_rmx_string_format
.format(rt
.rt_refcnt
, rt
.rt_rmx
.rmx_pksent
) + " "
646 rtf_string_format
= "{0:>s}"
647 if (rt
.rt_flags
& RTF_UP
):
648 out_string
+= rtf_string_format
.format("U")
649 if (rt
.rt_flags
& RTF_GATEWAY
):
650 out_string
+= rtf_string_format
.format("G")
651 if (rt
.rt_flags
& RTF_HOST
):
652 out_string
+= rtf_string_format
.format("H")
653 if (rt
.rt_flags
& RTF_REJECT
):
654 out_string
+= rtf_string_format
.format("R")
655 if (rt
.rt_flags
& RTF_DYNAMIC
):
656 out_string
+= rtf_string_format
.format("D")
657 if (rt
.rt_flags
& RTF_MODIFIED
):
658 out_string
+= rtf_string_format
.format("M")
659 if (rt
.rt_flags
& RTF_CLONING
):
660 out_string
+= rtf_string_format
.format("C")
661 if (rt
.rt_flags
& RTF_PRCLONING
):
662 out_string
+= rtf_string_format
.format("c")
663 if (rt
.rt_flags
& RTF_LLINFO
):
664 out_string
+= rtf_string_format
.format("L")
665 if (rt
.rt_flags
& RTF_STATIC
):
666 out_string
+= rtf_string_format
.format("S")
667 if (rt
.rt_flags
& RTF_PROTO1
):
668 out_string
+= rtf_string_format
.format("1")
669 if (rt
.rt_flags
& RTF_PROTO2
):
670 out_string
+= rtf_string_format
.format("2")
671 if (rt
.rt_flags
& RTF_PROTO3
):
672 out_string
+= rtf_string_format
.format("3")
673 if (rt
.rt_flags
& RTF_WASCLONED
):
674 out_string
+= rtf_string_format
.format("W")
675 if (rt
.rt_flags
& RTF_BROADCAST
):
676 out_string
+= rtf_string_format
.format("b")
677 if (rt
.rt_flags
& RTF_MULTICAST
):
678 out_string
+= rtf_string_format
.format("m")
679 if (rt
.rt_flags
& RTF_XRESOLVE
):
680 out_string
+= rtf_string_format
.format("X")
681 if (rt
.rt_flags
& RTF_BLACKHOLE
):
682 out_string
+= rtf_string_format
.format("B")
683 if (rt
.rt_flags
& RTF_IFSCOPE
):
684 out_string
+= rtf_string_format
.format("I")
685 if (rt
.rt_flags
& RTF_CONDEMNED
):
686 out_string
+= rtf_string_format
.format("Z")
687 if (rt
.rt_flags
& RTF_IFREF
):
688 out_string
+= rtf_string_format
.format("i")
689 if (rt
.rt_flags
& RTF_PROXY
):
690 out_string
+= rtf_string_format
.format("Y")
691 if (rt
.rt_flags
& RTF_ROUTER
):
692 out_string
+= rtf_string_format
.format("r")
695 out_string
+= str(rt
.rt_ifp
.if_name
)
696 out_string
+= str(int(rt
.rt_ifp
.if_unit
))
702 def GetRtTableAsString(rt_tables
):
704 rn
= Cast(rt_tables
.rnh_treetop
, 'radix_node *')
705 rnh_cnt
= rt_tables
.rnh_cnt
707 while (rn
.rn_bit
>= 0):
708 rn
= rn
.rn_u
.rn_node
.rn_L
711 base
= Cast(rn
, 'radix_node *')
712 while ((rn
.rn_parent
.rn_u
.rn_node
.rn_R
== rn
) and (rn
.rn_flags
& RNF_ROOT
== 0)):
714 rn
= rn
.rn_parent
.rn_u
.rn_node
.rn_R
715 while (rn
.rn_bit
>= 0):
716 rn
= rn
.rn_u
.rn_node
.rn_L
720 base
= rn
.rn_u
.rn_leaf
.rn_Dupedkey
721 if ((rn
.rn_flags
& RNF_ROOT
) == 0):
722 rt
= Cast(rn
, 'rtentry *')
723 if (kern
.ptrsize
== 8):
724 rtentry_string_format
= "0x{0:<18x}"
725 out_string
+= rtentry_string_format
.format(rt
) + " "
727 rtentry_string_format
= "0x{0:<10x}"
728 out_string
+= rtentry_string_format
.format(rt
) + " "
729 out_string
+= GetRtEntryPrDetailsAsString(rt
) + " "
732 if ((rn
.rn_flags
& RNF_ROOT
) != 0):
736 def GetRtInetAsString():
737 rt_tables
= kern
.globals.rt_tables
[2]
738 if (kern
.ptrsize
== 8):
739 rt_table_header_format_string
= "{0:<18s} {1: <16s} {2:<20s} {3:<16s} {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("-" * 18, "-" * 16, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8)
742 print GetRtTableAsString(rt_tables
)
744 rt_table_header_format_string
= "{0:<8s} {1:<16s} {2:<18s} {3:<8s} {4:<8s} {5:<8s} {6:<8s}"
745 print rt_table_header_format_string
.format("rtentry", "dst", "gw", "parent", "Refs", "Use", "flags/if")
746 print rt_table_header_format_string
.format("-" * 8, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8, "-" * 8)
747 print GetRtTableAsString(rt_tables
)
749 def GetRtInet6AsString():
750 rt_tables
= kern
.globals.rt_tables
[30]
751 if (kern
.ptrsize
== 8):
752 rt_table_header_format_string
= "{0:<18s} {1: <16s} {2:<20s} {3:<16s} {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("-" * 18, "-" * 16, "-" * 16, "-" * 16, "-" * 8, "-" * 8, "-" * 8)
755 print GetRtTableAsString(rt_tables
)
757 rt_table_header_format_string
= "{0:<8s} {1:<16s} {2:<18s} {3:<8s} {4:<8s} {5:<8s} {6:<8s}"
758 print rt_table_header_format_string
.format("rtentry", "dst", "gw", "parent", "Refs", "Use", "flags/if")
759 print rt_table_header_format_string
.format("-" * 8, "-" * 16, "-" * 18, "-" * 8, "-" * 8, "-" * 8, "-" * 8)
760 print GetRtTableAsString(rt_tables
)
762 # Macro: show_rt_inet
763 @lldb_command('show_rt_inet')
764 def ShowRtInet(cmd_args
=None):
765 """ Display the IPv4 routing table
767 print GetRtInetAsString()
768 # EndMacro: show_rt_inet
770 # Macro: show_rt_inet6
771 @lldb_command('show_rt_inet6')
772 def ShowRtInet6(cmd_args
=None):
773 """ Display the IPv6 routing table
775 print GetRtInet6AsString()
776 # EndMacro: show_rt_inet6
778 # Macro: rtentry_showdbg
779 @lldb_command('rtentry_showdbg')
780 def ShowRtEntryDebug(cmd_args
=None):
781 """ Print the debug information of a route entry
783 if (cmd_args
== None or len(cmd_args
) == 0):
784 print "Missing argument 0 in user function."
788 rtd
= kern
.GetValueFromAddress(cmd_args
[0], 'rtentry_dbg *')
789 rtd_summary_format_string
= "{0:s} {1:d}"
790 out_string
+= rtd_summary_format_string
.format("Total holds : ", rtd
.rtd_refhold_cnt
) + "\n"
791 out_string
+= rtd_summary_format_string
.format("Total releases : ", rtd
.rtd_refrele_cnt
) + "\n"
794 while (ix
< CTRACE_STACK_SIZE
):
795 kgm_pc
= rtd
.rtd_alloc
.pc
[ix
]
798 out_string
+= "\nAlloc: (thread " + hex(rtd
.rtd_alloc
.th
) + "):\n"
799 out_string
+= str(int(ix
+ 1)) + ": "
800 out_string
+= GetSourceInformationForAddress(kgm_pc
)
805 while (ix
< CTRACE_STACK_SIZE
):
806 kgm_pc
= rtd
.rtd_free
.pc
[ix
]
809 out_string
+= "\nFree: (thread " + hex(rtd
.rtd_free
.th
) + "):\n"
810 out_string
+= str(int(ix
+ 1)) + ": "
811 out_string
+= GetSourceInformationForAddress(kgm_pc
)
815 while (cnt
< RTD_TRACE_HIST_SIZE
):
817 while (ix
< CTRACE_STACK_SIZE
):
818 kgm_pc
= rtd
.rtd_refhold
[cnt
].pc
[ix
]
821 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(rtd
.rtd_refhold
[cnt
].th
) + "):\n"
822 out_string
+= str(int(ix
+ 1)) + ": "
823 out_string
+= GetSourceInformationForAddress(kgm_pc
)
829 while (cnt
< RTD_TRACE_HIST_SIZE
):
831 while (ix
< CTRACE_STACK_SIZE
):
832 kgm_pc
= rtd
.rtd_refrele
[cnt
].pc
[ix
]
835 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(rtd
.rtd_refrele
[cnt
].th
) + "):\n"
836 out_string
+= str(int(ix
+ 1)) + ": "
837 out_string
+= GetSourceInformationForAddress(kgm_pc
)
842 out_string
+= "\nTotal locks : " + str(int(rtd
.rtd_lock_cnt
))
843 out_string
+= "\nTotal unlocks : " + str(int(rtd
.rtd_unlock_cnt
))
846 while (cnt
< RTD_TRACE_HIST_SIZE
):
848 while (ix
< CTRACE_STACK_SIZE
):
849 kgm_pc
= rtd
.rtd_lock
[cnt
].pc
[ix
]
852 out_string
+= "\nLock [" + str(int(cnt
)) + "] (thread " + hex(rtd
.rtd_lock
[cnt
].th
) + "):\n"
853 out_string
+= str(int(ix
+ 1)) + ": "
854 out_string
+= GetSourceInformationForAddress(kgm_pc
)
860 while (cnt
< RTD_TRACE_HIST_SIZE
):
862 while (ix
< CTRACE_STACK_SIZE
):
863 kgm_pc
= rtd
.rtd_unlock
[cnt
].pc
[ix
]
866 out_string
+= "\nUnlock [" + str(int(cnt
)) + "] (thread " + hex(rtd
.rtd_unlock
[cnt
].th
) + "):\n"
867 out_string
+= str(int(ix
+ 1)) + ": "
868 out_string
+= GetSourceInformationForAddress(kgm_pc
)
874 # EndMacro: rtentry_showdbg
876 # Macro: inifa_showdbg
877 @lldb_command('inifa_showdbg')
878 def InIfaShowDebug(cmd_args
=None):
879 """ Print the debug information of an IPv4 interface address
881 if (cmd_args
== None or len(cmd_args
) == 0):
882 print "Missing argument 0 in user function."
886 inifa
= kern
.GetValueFromAddress(cmd_args
[0], 'in_ifaddr_dbg *')
887 in_ifaddr_summary_format_string
= "{0:s} {1:d}"
888 out_string
+= in_ifaddr_summary_format_string
.format("Total holds : ", inifa
.inifa_refhold_cnt
) + "\n"
889 out_string
+= in_ifaddr_summary_format_string
.format("Total releases : ", inifa
.inifa_refrele_cnt
) + "\n"
892 while (ix
< CTRACE_STACK_SIZE
):
893 kgm_pc
= inifa
.inifa_alloc
.pc
[ix
]
896 out_string
+= "\nAlloc: (thread " + hex(inifa
.inifa_alloc
.th
) + "):\n"
897 out_string
+= str(int(ix
+ 1)) + ": "
898 out_string
+= GetSourceInformationForAddress(kgm_pc
)
903 while (ix
< CTRACE_STACK_SIZE
):
904 kgm_pc
= inifa
.inifa_free
.pc
[ix
]
907 out_string
+= "\nFree: (thread " + hex(inifa
.inifa_free
.th
) + "):\n"
908 out_string
+= str(int(ix
+ 1)) + ": "
909 out_string
+= GetSourceInformationForAddress(kgm_pc
)
913 while (cnt
< INIFA_TRACE_HIST_SIZE
):
915 while (ix
< CTRACE_STACK_SIZE
):
916 kgm_pc
= inifa
.inifa_refhold
[cnt
].pc
[ix
]
919 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(inifa
.inifa_refhold
[cnt
].th
) + "):\n"
920 out_string
+= str(int(ix
+ 1)) + ": "
921 out_string
+= GetSourceInformationForAddress(kgm_pc
)
927 while (cnt
< INIFA_TRACE_HIST_SIZE
):
929 while (ix
< CTRACE_STACK_SIZE
):
930 kgm_pc
= inifa
.inifa_refrele
[cnt
].pc
[ix
]
933 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(inifa
.inifa_refrele
[cnt
].th
) + "):\n"
934 out_string
+= str(int(ix
+ 1)) + ": "
935 out_string
+= GetSourceInformationForAddress(kgm_pc
)
940 # EndMacro: inifa_showdbg
942 # Macro: in6ifa_showdbg
943 @lldb_command('in6ifa_showdbg')
944 def In6IfaShowDebug(cmd_args
=None):
945 """ Print the debug information of an IPv6 interface address
947 if (cmd_args
== None or len(cmd_args
) == 0):
948 print "Missing argument 0 in user function."
952 in6ifa
= kern
.GetValueFromAddress(cmd_args
[0], 'in6_ifaddr_dbg *')
953 in6_ifaddr_summary_format_string
= "{0:s} {1:d}"
954 print in6_ifaddr_summary_format_string
.format("Total holds : ", in6ifa
.in6ifa_refhold_cnt
)
955 print in6_ifaddr_summary_format_string
.format("Total releases : ", in6ifa
.in6ifa_refrele_cnt
)
958 while (ix
< CTRACE_STACK_SIZE
):
959 kgm_pc
= in6ifa
.in6ifa_alloc
.pc
[ix
]
962 out_string
+= "\nAlloc: (thread " + hex(in6ifa
.in6ifa_alloc
.th
) + "):\n"
963 out_string
+= str(int(ix
+ 1)) + ": "
964 out_string
+= GetSourceInformationForAddress(kgm_pc
)
969 while (ix
< CTRACE_STACK_SIZE
):
970 kgm_pc
= in6ifa
.in6ifa_free
.pc
[ix
]
973 out_string
+= "\nFree: (thread " + hex(in6ifa
.in6ifa_free
.th
) + "):\n"
974 out_string
+= str(int(ix
+ 1)) + ": "
975 out_string
+= GetSourceInformationForAddress(kgm_pc
)
979 while (cnt
< IN6IFA_TRACE_HIST_SIZE
):
981 while (ix
< CTRACE_STACK_SIZE
):
982 kgm_pc
= in6ifa
.in6ifa_refhold
[cnt
].pc
[ix
]
985 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(in6ifa
.in6ifa_refhold
[cnt
].th
) + "):\n"
986 out_string
+= str(int(ix
+ 1)) + ": "
987 out_string
+= GetSourceInformationForAddress(kgm_pc
)
993 while (cnt
< IN6IFA_TRACE_HIST_SIZE
):
995 while (ix
< CTRACE_STACK_SIZE
):
996 kgm_pc
= in6ifa
.in6ifa_refrele
[cnt
].pc
[ix
]
999 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(in6ifa
.in6ifa_refrele
[cnt
].th
) + "):\n"
1000 out_string
+= str(int(ix
+ 1)) + ": "
1001 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1006 # EndMacro: in6ifa_showdbg
1008 # Macro: inm_showdbg
1009 @lldb_command('inm_showdbg')
1010 def InmShowDebug(cmd_args
=None):
1011 """ Print the debug information of an IPv4 multicast address
1013 if (cmd_args
== None or len(cmd_args
) == 0):
1014 print "Missing argument 0 in user function."
1018 inm
= kern
.GetValueFromAddress(cmd_args
[0], 'in_multi_dbg *')
1019 in_multi_summary_format_string
= "{0:s} {1:d}"
1020 out_string
+= in_multi_summary_format_string
.format("Total holds : ", inm
.inm_refhold_cnt
)
1021 out_string
+= in_multi_summary_format_string
.format("Total releases : ", inm
.inm_refrele_cnt
)
1023 while (cnt
< INM_TRACE_HIST_SIZE
):
1025 while (ix
< CTRACE_STACK_SIZE
):
1026 kgm_pc
= inm
.inm_refhold
[cnt
].pc
[ix
]
1029 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(inm
.inm_refhold
[cnt
].th
) + "):\n"
1030 out_string
+= str(int(ix
+ 1)) + ": "
1031 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1036 while (cnt
< INM_TRACE_HIST_SIZE
):
1038 while (ix
< CTRACE_STACK_SIZE
):
1039 kgm_pc
= inm
.inm_refrele
[cnt
].pc
[ix
]
1042 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(inm
.inm_refrele
[cnt
].th
) + "):\n"
1043 out_string
+= str(int(ix
+ 1)) + ": "
1044 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1049 # EndMacro: inm_showdbg
1051 # Macro: ifma_showdbg
1052 @lldb_command('ifma_showdbg')
1053 def IfmaShowDebug(cmd_args
=None):
1054 """ Print the debug information of a link multicast address
1056 if (cmd_args
== None or len(cmd_args
) == 0):
1057 print "Missing argument 0 in user function."
1061 ifma
= kern
.GetValueFromAddress(cmd_args
[0], 'ifmultiaddr_dbg *')
1062 link_multi_summary_format_string
= "{0:s} {1:d}"
1063 out_string
+= link_multi_summary_format_string
.format("Total holds : ", ifma
.ifma_refhold_cnt
) + "\n"
1064 out_string
+= link_multi_summary_format_string
.format("Total releases : ", ifma
.ifma_refrele_cnt
) + "\n"
1066 while (cnt
< IFMA_TRACE_HIST_SIZE
):
1068 while (ix
< CTRACE_STACK_SIZE
):
1069 kgm_pc
= ifma
.ifma_refhold
[cnt
].pc
[ix
]
1072 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(ifma
.ifma_refhold
[cnt
].th
) + "):\n"
1073 out_string
+= str(int(ix
+ 1)) + ": "
1074 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1079 while (cnt
< IFMA_TRACE_HIST_SIZE
):
1081 while (ix
< CTRACE_STACK_SIZE
):
1082 kgm_pc
= ifma
.ifma_refrele
[cnt
].pc
[ix
]
1085 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(ifma
.ifma_refrele
[cnt
].th
) + "):\n"
1086 out_string
+= str(int(ix
+ 1)) + ": "
1087 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1092 # EndMacro: ifma_showdbg
1094 # Macro: ifpref_showdbg
1095 @lldb_command('ifpref_showdbg')
1096 def IfpRefShowDebug(cmd_args
=None):
1097 """ Print the debug information of an interface ref count
1099 if (cmd_args
== None or len(cmd_args
) == 0):
1100 print "Missing argument 0 in user function."
1104 dl_if
= kern
.GetValueFromAddress(cmd_args
[0], 'dlil_ifnet_dbg *')
1105 dl_if_summary_format_string
= "{0:s} {1:d}"
1106 out_string
+= dl_if_summary_format_string
.format("Total holds : ", dl_if
.dldbg_if_refhold_cnt
)
1107 out_string
+= dl_if_summary_format_string
.format("Total releases : ", dl_if
.dldbg_if_refrele_cnt
)
1109 while (cnt
< IF_REF_TRACE_HIST_SIZE
):
1111 while (ix
< CTRACE_STACK_SIZE
):
1112 kgm_pc
= dl_if
.dldbg_if_refhold
[cnt
].pc
[ix
]
1115 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(dl_if
.dldbg_if_refhold
[cnt
].th
) + "):\n"
1116 out_string
+= str(int(ix
+ 1)) + ": "
1117 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1122 while (cnt
< IF_REF_TRACE_HIST_SIZE
):
1124 while (ix
< CTRACE_STACK_SIZE
):
1125 kgm_pc
= dl_if
.dldbg_if_refrele
[cnt
].pc
[ix
]
1128 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(dl_if
.dldbg_if_refrele
[cnt
].th
) + "):\n"
1129 out_string
+= str(int(ix
+ 1)) + ": "
1130 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1135 # EndMacro: ifpref_showdbg
1137 # Macro: ndpr_showdbg
1138 @lldb_command('ndpr_showdbg')
1139 def ndprShowDebug(cmd_args
=None):
1140 """ Print the debug information of a nd_prefix structure
1142 if (cmd_args
== None or len(cmd_args
) == 0):
1143 print "Missing argument 0 in user function."
1147 ndpr
= kern
.GetValueFromAddress(cmd_args
[0], 'nd_prefix_dbg *')
1148 ndpr_summary_format_string
= "{0:s} {1:d}"
1149 out_string
+= ndpr_summary_format_string
.format("Total holds : ", ndpr
.ndpr_refhold_cnt
)
1150 out_string
+= ndpr_summary_format_string
.format("Total releases : ", ndpr
.ndpr_refrele_cnt
)
1152 while (cnt
< NDPR_TRACE_HIST_SIZE
):
1154 while (ix
< CTRACE_STACK_SIZE
):
1155 kgm_pc
= ndpr
.ndpr_refhold
[cnt
].pc
[ix
]
1158 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(ndpr
.ndpr_refhold
[cnt
].th
) + "):\n"
1159 out_string
+= str(int(ix
+ 1)) + ": "
1160 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1165 while (cnt
< NDPR_TRACE_HIST_SIZE
):
1167 while (ix
< CTRACE_STACK_SIZE
):
1168 kgm_pc
= ndpr
.ndpr_refrele
[cnt
].pc
[ix
]
1171 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(ndpr
.ndpr_refrele
[cnt
].th
) + "):\n"
1172 out_string
+= str(int(ix
+ 1)) + ": "
1173 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1178 # EndMacro: ndpr_showdbg
1180 # Macro: nddr_showdbg
1181 @lldb_command('nddr_showdbg')
1182 def nddrShowDebug(cmd_args
=None):
1183 """ Print the debug information of a nd_defrouter structure
1185 if (cmd_args
== None or len(cmd_args
) == 0):
1186 print "Missing argument 0 in user function."
1190 nddr
= kern
.GetValueFromAddress(cmd_args
[0], 'nd_defrouter_dbg *')
1191 nddr_summary_format_string
= "{0:s} {1:d}"
1192 out_string
+= nddr_summary_format_string
.format("Total holds : ", nddr
.nddr_refhold_cnt
)
1193 out_string
+= nddr_summary_format_string
.format("Total releases : ", nddr
.nddr_refrele_cnt
)
1195 while (cnt
< NDDR_TRACE_HIST_SIZE
):
1197 while (ix
< CTRACE_STACK_SIZE
):
1198 kgm_pc
= nddr
.nddr_refhold
[cnt
].pc
[ix
]
1201 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(nddr
.nddr_refhold
[cnt
].th
) + "):\n"
1202 out_string
+= str(int(ix
+ 1)) + ": "
1203 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1208 while (cnt
< NDDR_TRACE_HIST_SIZE
):
1210 while (ix
< CTRACE_STACK_SIZE
):
1211 kgm_pc
= nddr
.nddr_refrele
[cnt
].pc
[ix
]
1214 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(nddr
.nddr_refrele
[cnt
].th
) + "):\n"
1215 out_string
+= str(int(ix
+ 1)) + ": "
1216 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1221 # EndMacro: nddr_showdbg
1223 # Macro: imo_showdbg
1224 @lldb_command('imo_showdbg')
1225 def IpmOptions(cmd_args
=None):
1226 """ Print the debug information of a ip_moptions structure
1228 if (cmd_args
== None or len(cmd_args
) == 0):
1229 print "Missing argument 0 in user function."
1233 imo
= kern
.GetValueFromAddress(cmd_args
[0], 'ip_moptions_dbg *')
1234 imo_summary_format_string
= "{0:s} {1:d}"
1235 out_string
+= imo_summary_format_string
.format("Total holds : ", imo
.imo_refhold_cnt
)
1236 out_string
+= imo_summary_format_string
.format("Total releases : ", imo
.imo_refrele_cnt
)
1238 while (cnt
< IMO_TRACE_HIST_SIZE
):
1240 while (ix
< CTRACE_STACK_SIZE
):
1241 kgm_pc
= imo
.imo_refhold
[cnt
].pc
[ix
]
1244 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(imo
.imo_refhold
[cnt
].th
) + "):\n"
1245 out_string
+= str(int(ix
+ 1)) + ": "
1246 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1251 while (cnt
< IMO_TRACE_HIST_SIZE
):
1253 while (ix
< CTRACE_STACK_SIZE
):
1254 kgm_pc
= imo
.imo_refrele
[cnt
].pc
[ix
]
1257 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(imo
.imo_refrele
[cnt
].th
) + "):\n"
1258 out_string
+= str(int(ix
+ 1)) + ": "
1259 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1264 # EndMacro: imo_showdbg
1266 # Macro: im6o_showdbg
1267 @lldb_command('im6o_showdbg')
1268 def IpmOptions(cmd_args
=None):
1269 """ Print the debug information of a ip6_moptions structure
1271 if (cmd_args
== None or len(cmd_args
) == 0):
1272 print "Missing argument 0 in user function."
1276 im6o
= kern
.GetValueFromAddress(cmd_args
[0], 'ip6_moptions_dbg *')
1277 im6o_summary_format_string
= "{0:s} {1:d}"
1278 out_string
+= im6o_summary_format_string
.format("Total holds : ", im6o
.im6o_refhold_cnt
)
1279 out_string
+= im6o_summary_format_string
.format("Total releases : ", im6o
.im6o_refrele_cnt
)
1281 while (cnt
< IM6O_TRACE_HIST_SIZE
):
1283 while (ix
< CTRACE_STACK_SIZE
):
1284 kgm_pc
= im6o
.im6o_refhold
[cnt
].pc
[ix
]
1287 out_string
+= "\nHold [" + str(int(cnt
)) + "] (thread " + hex(im6o
.im6o_refhold
[cnt
].th
) + "):\n"
1288 out_string
+= str(int(ix
+ 1)) + ": "
1289 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1294 while (cnt
< IM6O_TRACE_HIST_SIZE
):
1296 while (ix
< CTRACE_STACK_SIZE
):
1297 kgm_pc
= im6o
.im6o_refrele
[cnt
].pc
[ix
]
1300 out_string
+= "\nRelease [" + str(int(cnt
)) + "] (thread " + hex(im6o
.im6o_refrele
[cnt
].th
) + "):\n"
1301 out_string
+= str(int(ix
+ 1)) + ": "
1302 out_string
+= GetSourceInformationForAddress(kgm_pc
)
1307 # EndMacro: im6o_showdbg
1309 # Macro: rtentry_trash
1310 @lldb_command('rtentry_trash')
1311 def RtEntryTrash(cmd_args
=None):
1312 """ Walk the list of trash route entries
1315 rt_trash_head
= kern
.globals.rttrash_head
1316 rtd
= Cast(rt_trash_head
.tqh_first
, 'rtentry_dbg *')
1317 rt_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1319 while (int(rtd
) != 0):
1321 if (kern
.ptrsize
== 8):
1322 print " rtentry ref hold rele dst gw parent flags/if\n"
1323 print " ----------------- --- ------ ------ --------------- ----- ------------------ -----------\n"
1325 print " rtentry ref hold rele dst gw parent flags/if\n"
1326 print " --------- --- ------ ------ --------------- ----- ---------- -----------\n"
1327 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
) + " "
1328 out_string
+= GetRtEntryPrDetailsAsString(rtd
) + "\n"
1329 rtd
= rtd
.rtd_trash_link
.tqe_next
1332 # EndMacro: rtentry_trash
1334 # Macro: show_rtentry
1335 @lldb_command('show_rtentry')
1336 def ShRtEntry(cmd_args
=None):
1340 rt
= kern
.GetValueFromAddress(cmd_args
[0], 'rtentry *')
1341 out_string
+= GetRtEntryPrDetailsAsString(rt
) + "\n"
1343 # EndMacro: show_rtentry
1345 # Macro: inifa_trash
1346 @lldb_command('inifa_trash')
1347 def InIfaTrash(cmd_args
=None):
1348 """ Walk the list of trash in_ifaddr entries
1351 ifa_trash_head
= kern
.globals.inifa_trash_head
1352 ifa
= Cast(ifa_trash_head
.tqh_first
, 'in_ifaddr_dbg *')
1353 inifa_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1355 while (int(ifa
) != 0):
1357 if (kern
.ptrsize
== 8):
1358 print " in_ifa ref hold rele"
1359 print " ------------------ --- ------ ----"
1361 print " in_ifa ref hold rele"
1362 print " ---------- --- ----- ------"
1363 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
) + " "
1364 out_string
+= GetSocketAddrAsStringInet(ifa
.inifa
.ia_ifa
.ifa_addr
) + "\n"
1365 ifa
= ifa
.inifa_trash_link
.tqe_next
1368 # EndMacro: inifa_trash
1370 # Macro: in6ifa_trash
1371 @lldb_command('in6ifa_trash')
1372 def In6IfaTrash(cmd_args
=None):
1373 """ Walk the list of trash in6_ifaddr entries
1376 in6ifa_trash_head
= kern
.globals.in6ifa_trash_head
1377 ifa
= Cast(in6ifa_trash_head
.tqh_first
, 'in6_ifaddr_dbg *')
1378 in6ifa_trash_format_string
= "{0:4d}: 0x{1:x} {2:3d} {3:6d} {4:6d}"
1380 while (int(ifa
) != 0):
1382 if (kern
.ptrsize
== 8):
1383 print " in6_ifa ref hold rele"
1384 print " ------------------ --- ------ ------"
1386 print " in6_ifa ref hold rele"
1387 print " ---------- --- ------ ------"
1388 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
) + " "
1389 out_string
+= GetSocketAddrAsStringInet6(ifa
.in6ifa
.ia_ifa
.ifa_addr
) + "\n"
1390 ifa
= ifa
.in6ifa_trash_link
.tqe_next
1393 # EndMacro: in6ifa_trash
1396 @lldb_command('inm_trash')
1397 def InmTrash(cmd_args
=None):
1398 """ Walk the list of trash in_multi entries
1401 inm_trash_head
= kern
.globals.inm_trash_head
1402 inm
= Cast(inm_trash_head
.tqh_first
, 'in_multi_dbg *')
1403 inm_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1405 while (int(inm
) != 0):
1407 if (kern
.ptrsize
== 8):
1408 print " inm ref hold rele"
1409 print " ------------------ --- ------ ------"
1411 print " inm ref hold rele"
1412 print " ---------- --- ------ ------"
1413 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
) + " "
1414 out_string
+= GetInAddrAsString(addressof(inm
.inm
.inm_addr
)) + "\n"
1415 inm
= inm
.inm_trash_link
.tqe_next
1418 # EndMacro: inm_trash
1421 @lldb_command('in6m_trash')
1422 def In6mTrash(cmd_args
=None):
1423 """ Walk the list of trash in6_multi entries
1426 in6m_trash_head
= kern
.globals.in6m_trash_head
1427 in6m
= Cast(in6m_trash_head
.tqh_first
, 'in6_multi_dbg *')
1428 in6m_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1430 while (int(in6m
) != 0):
1432 if (kern
.ptrsize
== 8):
1433 print " in6m ref hold rele"
1434 print " ------------------ --- ------ ------"
1436 print " in6m ref hold rele"
1437 print " ---------- --- ------ ------"
1438 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
) + " "
1439 out_string
+= GetIn6AddrAsString(addressof(in6m
.in6m
.in6m_addr
)) + "\n"
1440 in6m
= in6m
.in6m_trash_link
.tqe_next
1443 # EndMacro: in6m_trash
1446 @lldb_command('ifma_trash')
1447 def IfmaTrash(cmd_args
=None):
1448 """ Walk the list of trash ifmultiaddr entries
1451 ifma_trash_head
= kern
.globals.ifma_trash_head
1452 ifma
= Cast(ifma_trash_head
.tqh_first
, 'ifmultiaddr_dbg *')
1453 ifma_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1455 while (int(ifma
) != 0):
1457 if (kern
.ptrsize
== 8):
1458 print " ifma ref hold rele"
1459 print " ------------------ --- ------ ------"
1461 print " ifma ref hold rele"
1462 print " ---------- --- ------ ------"
1463 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
) + " "
1464 out_string
+= GetSocketAddrAsString(ifma
.ifma
.ifma_addr
) + "\n"
1465 out_string
+= " @ " + ifma
.ifma
.ifma_ifp
.if_xname
1466 ifma
= ifma
.ifma_trash_link
.tqe_next
1469 # EndMacro: ifma_trash
1471 def GetInPcb(pcb
, proto
):
1473 out_string
+= hex(pcb
)
1475 if (proto
== IPPROTO_TCP
):
1476 out_string
+= " tcp"
1478 if (proto
== IPPROTO_UDP
):
1479 out_string
+= " udp"
1481 out_string
+= str(proto
) + "."
1482 if (pcb
.inp_vflag
& INP_IPV4
):
1484 if (pcb
.inp_vflag
& INP_IPV6
):
1487 if (pcb
.inp_vflag
& INP_IPV4
):
1489 out_string
+= GetInAddrAsString(addressof(pcb
.inp_dependladdr
.inp46_local
.ia46_addr4
))
1491 out_string
+= GetIn6AddrAsString((pcb
.inp_dependladdr
.inp6_local
.__u6_addr
.__u6_addr
8))
1494 out_string
+= Getntohs(pcb
.inp_lport
)
1497 if (pcb
.inp_vflag
& INP_IPV4
):
1499 out_string
+= GetInAddrAsString(addressof(pcb
.inp_dependfaddr
.inp46_foreign
.ia46_addr4
))
1501 out_string
+= GetIn6AddrAsString((pcb
.inp_dependfaddr
.inp6_foreign
.__u6_addr
.__u6_addr
8))
1504 out_string
+= Getntohs(pcb
.inp_fport
)
1507 if (proto
== IPPROTO_TCP
):
1508 out_string
+= GetTcpState(pcb
.inp_ppcb
)
1510 if (pcb
.inp_flags
& INP_RECVOPTS
):
1511 out_string
+= "recvopts "
1512 if (pcb
.inp_flags
& INP_RECVRETOPTS
):
1513 out_string
+= "recvretopts "
1514 if (pcb
.inp_flags
& INP_RECVDSTADDR
):
1515 out_string
+= "recvdstaddr "
1516 if (pcb
.inp_flags
& INP_HDRINCL
):
1517 out_string
+= "hdrincl "
1518 if (pcb
.inp_flags
& INP_HIGHPORT
):
1519 out_string
+= "highport "
1520 if (pcb
.inp_flags
& INP_LOWPORT
):
1521 out_string
+= "lowport "
1522 if (pcb
.inp_flags
& INP_ANONPORT
):
1523 out_string
+= "anonport "
1524 if (pcb
.inp_flags
& INP_RECVIF
):
1525 out_string
+= "recvif "
1526 if (pcb
.inp_flags
& INP_MTUDISC
):
1527 out_string
+= "mtudisc "
1528 if (pcb
.inp_flags
& INP_STRIPHDR
):
1529 out_string
+= "striphdr "
1530 if (pcb
.inp_flags
& INP_RECV_ANYIF
):
1531 out_string
+= "recv_anyif "
1532 if (pcb
.inp_flags
& INP_INADDR_ANY
):
1533 out_string
+= "inaddr_any "
1534 if (pcb
.inp_flags
& INP_RECVTTL
):
1535 out_string
+= "recvttl "
1536 if (pcb
.inp_flags
& INP_UDP_NOCKSUM
):
1537 out_string
+= "nocksum "
1538 if (pcb
.inp_flags
& INP_BOUND_IF
):
1539 out_string
+= "boundif "
1540 if (pcb
.inp_flags
& IN6P_IPV6_V6ONLY
):
1541 out_string
+= "v6only "
1542 if (pcb
.inp_flags
& IN6P_PKTINFO
):
1543 out_string
+= "pktinfo "
1544 if (pcb
.inp_flags
& IN6P_HOPLIMIT
):
1545 out_string
+= "hoplimit "
1546 if (pcb
.inp_flags
& IN6P_HOPOPTS
):
1547 out_string
+= "hopopts "
1548 if (pcb
.inp_flags
& IN6P_DSTOPTS
):
1549 out_string
+= "dstopts "
1550 if (pcb
.inp_flags
& IN6P_RTHDR
):
1551 out_string
+= "rthdr "
1552 if (pcb
.inp_flags
& IN6P_RTHDRDSTOPTS
):
1553 out_string
+= "rthdrdstopts "
1554 if (pcb
.inp_flags
& IN6P_TCLASS
):
1555 out_string
+= "rcv_tclass "
1556 if (pcb
.inp_flags
& IN6P_AUTOFLOWLABEL
):
1557 out_string
+= "autoflowlabel "
1558 if (pcb
.inp_flags
& IN6P_BINDV6ONLY
):
1559 out_string
+= "bindv6only "
1560 if (pcb
.inp_flags
& IN6P_RFC2292
):
1561 out_string
+= "RFC2292 "
1562 if (pcb
.inp_flags
& IN6P_MTU
):
1563 out_string
+= "rcv_pmtu "
1564 if (pcb
.inp_flags
& INP_PKTINFO
):
1565 out_string
+= "pktinfo "
1566 if (pcb
.inp_flags
& INP_FLOW_SUSPENDED
):
1567 out_string
+= "suspended "
1568 if (pcb
.inp_flags
& INP_NO_IFT_CELLULAR
):
1569 out_string
+= "nocellular "
1570 if (pcb
.inp_flags
& INP_FLOW_CONTROLLED
):
1571 out_string
+= "flowctld "
1572 if (pcb
.inp_flags
& INP_FC_FEEDBACK
):
1573 out_string
+= "fcfeedback "
1574 if (pcb
.inp_flags2
& INP2_TIMEWAIT
):
1575 out_string
+= "timewait "
1576 if (pcb
.inp_flags2
& INP2_IN_FCTREE
):
1577 out_string
+= "in_fctree "
1578 if (pcb
.inp_flags2
& INP2_WANT_APP_POLICY
):
1579 out_string
+= "want_app_policy "
1583 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
)) + "] "
1585 if (pcb
.inp_state
== 0 or pcb
.inp_state
== INPCB_STATE_INUSE
):
1586 out_string
+= "inuse, "
1588 if (pcb
.inp_state
== INPCB_STATE_DEAD
):
1589 out_string
+= "dead, "
1591 out_string
+= "unknown (" + str(int(pcb
.inp_state
)) + "), "
1595 def GetPcbInfo(pcbi
, proto
):
1598 snd_buf
= unsigned(0)
1600 rcv_buf
= unsigned(0)
1602 out_string
+= "lastport " + str(int(pcbi
.ipi_lastport
)) + " lastlow " + str(int(pcbi
.ipi_lastlow
)) + " lasthi " + str(int(pcbi
.ipi_lasthi
)) + "\n"
1603 out_string
+= "active pcb count is " + str(int(pcbi
.ipi_count
)) + "\n"
1604 hashsize
= pcbi
.ipi_hashmask
+ 1
1605 out_string
+= "hash size is " + str(int(hashsize
)) + "\n"
1606 out_string
+= str(pcbi
.ipi_hashbase
) + " has the following inpcb(s):\n"
1607 if (kern
.ptrsize
== 8):
1608 out_string
+= "pcb proto source address port destination address port\n"
1610 out_string
+= "pcb proto source address port destination address port\n\n"
1613 hashbase
= pcbi
.ipi_hashbase
1614 while (i
< hashsize
):
1616 pcb
= cast(head
.lh_first
, 'inpcb *')
1619 out_string
+= GetInPcb(pcb
, proto
) + "\n"
1622 snd_cc
+= so
.so_snd
.sb_cc
1623 mp
= so
.so_snd
.sb_mb
1626 if (mp
.m_hdr
.mh_flags
& 0x01):
1627 snd_buf
+= mp
.M_dat
.MH
.MH_dat
.MH_ext
.ext_size
1628 mp
= mp
.m_hdr
.mh_next
1629 rcv_cc
+= so
.so_rcv
.sb_cc
1630 mp
= so
.so_rcv
.sb_mb
1633 if (mp
.m_hdr
.mh_flags
& 0x01):
1634 rcv_buf
+= mp
.M_dat
.MH
.MH_dat
.MH_ext
.ext_size
1635 mp
= mp
.m_hdr
.mh_next
1636 pcb
= cast(pcb
.inp_hash
.le_next
, 'inpcb *')
1639 out_string
+= "total seen " + str(int(pcbseen
)) + " snd_cc " + str(int(snd_cc
)) + " rcv_cc " + str(int(rcv_cc
)) + "\n"
1640 out_string
+= "total snd_buf " + str(int(snd_buf
)) + " rcv_buf " + str(int(rcv_buf
)) + "\n"
1641 out_string
+= "port hash base is " + hex(pcbi
.ipi_porthashbase
) + "\n"
1644 hashbase
= pcbi
.ipi_porthashbase
1645 while (i
< hashsize
):
1647 pcb
= cast(head
.lh_first
, 'inpcbport *')
1650 out_string
+= GetInPcbPort(pcb
)
1652 pcb
= cast(pcb
.phd_hash
.le_next
, 'inpcbport *')
1657 def GetInPcbPort(ppcb
):
1659 out_string
+= hex(ppcb
) + ": lport "
1660 out_string
+= Getntohs(ppcb
.phd_port
)
1666 #p = unsigned(int(port) & 0x0000ffff)
1667 p
= ((port
& 0x0000ff00) >> 8)
1668 p |
= ((port
& 0x000000ff) << 8)
1671 # Macro: show_kern_event_pcbinfo
1672 def GetKernEventPcbInfo(kev_pcb_head
):
1674 pcb
= Cast(kev_pcb_head
.lh_first
, 'kern_event_pcb *')
1675 if (kern
.ptrsize
== 8):
1676 kev_pcb_format_string
= "0x{0:<16x} {1:12d} {2:16d} {3:16d}"
1677 out_string
+= " evp socket vendor code class filter subclass filter\n"
1678 out_string
+= "-------------- ----------- ------------ ---------------\n"
1680 kev_pcb_format_string
= "0x{0:<8x} {1:12d} {2:16d} {3:16d}"
1681 out_string
+= "evp socket vendor code class filter subclass filter\n"
1682 out_string
+= "---------- ----------- ------------ ---------------\n"
1684 out_string
+= kev_pcb_format_string
.format(pcb
.evp_socket
, pcb
.evp_vendor_code_filter
, pcb
.evp_class_filter
, pcb
.evp_subclass_filter
)
1686 pcb
= pcb
.evp_link
.le_next
1689 @lldb_command('show_kern_event_pcbinfo')
1690 def ShowKernEventPcbInfo(cmd_args
=None):
1691 """ Display the list of Kernel Event protocol control block information
1693 print GetKernEventPcbInfo(addressof(kern
.globals.kern_event_head
))
1694 # EndMacro: show_kern_event_pcbinfo
1696 # Macro: show_kern_control_pcbinfo
1697 def GetKernControlPcbInfo(ctl_head
):
1699 kctl
= Cast(ctl_head
.tqh_first
, 'kctl *')
1700 if (kern
.ptrsize
== 8):
1701 kcb_format_string
= "0x{0:<16x} {1:4d} {2:10d}\n"
1703 kcb_format_string
= "0x{0:<8x} {1:4d} {2:10d}\n"
1704 while unsigned(kctl
) != 0:
1705 kctl_name
= "controller: " + str(kctl
.name
) + "\n"
1706 out_string
+= kctl_name
1707 kcb
= Cast(kctl
.kcb_head
.tqh_first
, 'ctl_cb *')
1708 if unsigned(kcb
) != 0:
1709 if (kern
.ptrsize
== 8):
1710 out_string
+= "socket unit usecount\n"
1711 out_string
+= "------ ---- --------\n"
1713 out_string
+= "socket unit usecount\n"
1714 out_string
+= "------ ---- --------\n"
1715 while unsigned(kcb
) != 0:
1716 out_string
+= kcb_format_string
.format(kcb
.so
, kcb
.unit
, kcb
.usecount
)
1717 kcb
= kcb
.next
.tqe_next
1719 kctl
= kctl
.next
.tqe_next
1722 @lldb_command('show_kern_control_pcbinfo')
1723 def ShowKernControlPcbInfo(cmd_args
=None):
1724 """ Display the list of Kernel Control protocol control block information
1726 print GetKernControlPcbInfo(addressof(kern
.globals.ctl_head
))
1727 # EndMacro: show_kern_control_pcbinfo
1729 # Macro: show_tcp_pcbinfo
1730 @lldb_command('show_tcp_pcbinfo')
1731 def ShowTcpPcbInfo(cmd_args
=None):
1732 """ Display the list of TCP protocol control block information
1734 print GetPcbInfo(addressof(kern
.globals.tcbinfo
), IPPROTO_TCP
)
1735 # EndMacro: show_tcp_pcbinfo
1737 # Macro: show_udp_pcbinfo
1738 @lldb_command('show_udp_pcbinfo')
1739 def ShowUdpPcbInfo(cmd_args
=None):
1740 """ Display the list of UDP protocol control block information
1742 print GetPcbInfo(addressof(kern
.globals.udbinfo
), IPPROTO_UDP
)
1743 # EndMacro: show_udp_pcbinfo
1745 # Macro: show_tcp_timewaitslots
1746 @lldb_command('show_tcp_timewaitslots')
1747 def ShowTcpTimeWaitSlots(cmd_args
=None):
1748 """ Display the list of the TCP protocol control blocks in TIMEWAIT
1754 if len(cmd_args
) > 0:
1755 if (int(cmd_args
[0]) == -1):
1758 slot
= int(cmd_args
[0])
1760 out_string
+= "time wait slot size " + str(N_TIME_WAIT_SLOTS
) + " cur_tw_slot " + str(int(kern
.globals.cur_tw_slot
)) + "\n"
1763 while (i
< N_TIME_WAIT_SLOTS
):
1765 head
= kern
.globals.time_wait_slots
[i
]
1766 if (i
== slot
or slot
== -1):
1767 pcb0
= cast(head
.lh_first
, 'inpcb *')
1770 pcb0
= pcb0
.inp_list
.le_next
1772 out_string
+= " slot " + str(i
) + " count " + str(perslot
) + "\n"
1774 if (_all
or i
== slot
):
1775 pcb0
= cast(head
.lh_first
, 'inpcb *')
1778 out_string
+= GetInPcb(pcb0
, IPPROTO_TCP
)
1780 pcb0
= pcb0
.inp_list
.le_next
1784 # EndMacro: show_tcp_timewaitslots
1786 # Macro: show_domains
1787 @lldb_command('show_domains')
1788 def ShowDomains(cmd_args
=None):
1789 """ Display the list of the domains
1792 domains
= kern
.globals.domains
1793 dp
= Cast(domains
.tqh_first
, 'domain *')
1794 ifma_trash_format_string
= "{0:4d}: {1:x} {2:3d} {3:6d} {4:6d}"
1797 out_string
+= "\"" + str(dp
.dom_name
) + "\"" + "[" + str(int(dp
.dom_refs
)) + " refs] domain " + hex(dp
) + "\n"
1798 out_string
+= " family:\t" + str(int(dp
.dom_family
)) + "\n"
1799 out_string
+= " flags:0x\t" + str(int(dp
.dom_flags
)) + "\n"
1800 out_string
+= " rtparams:\toff=" + str(int(dp
.dom_rtoffset
)) + ", maxrtkey=" + str(int(dp
.dom_maxrtkey
)) + "\n"
1803 out_string
+= " init:\t"
1804 out_string
+= GetSourceInformationForAddress(dp
.dom_init
) + "\n"
1805 if (dp
.dom_externalize
):
1806 out_string
+= " externalize:\t"
1807 out_string
+= GetSourceInformationForAddress(dp
.dom_externalize
) + "\n"
1808 if (dp
.dom_dispose
):
1809 out_string
+= " dispose:\t"
1810 out_string
+= GetSourceInformationForAddress(dp
.dom_dispose
) + "\n"
1811 if (dp
.dom_rtattach
):
1812 out_string
+= " rtattach:\t"
1813 out_string
+= GetSourceInformationForAddress(dp
.dom_rtattach
) + "\n"
1815 out_string
+= " old:\t"
1816 out_string
+= GetSourceInformationForAddress(dp
.dom_old
) + "\n"
1818 pr
= Cast(dp
.dom_protosw
.tqh_first
, 'protosw *')
1821 out_string
+= "\ttype " + str(int(pr
.pr_type
)) + ", protocol " + str(int(pr
.pr_protocol
)) + ", protosw " + hex(pr
) + "\n"
1822 out_string
+= "\t flags:0x\t" + hex(pr
.pr_flags
) + "\n"
1824 out_string
+= "\t input:\t"
1825 out_string
+= GetSourceInformationForAddress(pr
.pr_input
) + "\n"
1827 out_string
+= "\t output:\t"
1828 out_string
+= GetSourceInformationForAddress(pr
.pr_output
) + "\n"
1829 if (pr
.pr_ctlinput
):
1830 out_string
+= "\t ctlinput:\t"
1831 out_string
+= GetSourceInformationForAddress(pr
.pr_ctlinput
) + "\n"
1832 if (pr
.pr_ctloutput
):
1833 out_string
+= "\t ctloutput:\t"
1834 out_string
+= GetSourceInformationForAddress(pr
.pr_ctloutput
) + "\n"
1836 out_string
+= "\t init:\t"
1837 out_string
+= GetSourceInformationForAddress(pr
.pr_init
) + "\n"
1839 out_string
+= "\t drain:\t"
1840 out_string
+= GetSourceInformationForAddress(pr
.pr_drain
) + "\n"
1842 out_string
+= "\t sysctl:\t"
1843 out_string
+= GetSourceInformationForAddress(pr
.pr_sysctl
) + "\n"
1845 out_string
+= "\t lock:\t"
1846 out_string
+= GetSourceInformationForAddress(pr
.pr_lock
) + "\n"
1848 out_string
+= "\t unlock:\t"
1849 out_string
+= GetSourceInformationForAddress(pr
.pr_unlock
) + "\n"
1851 out_string
+= "\t getlock:\t"
1852 out_string
+= GetSourceInformationForAddress(pr
.pr_getlock
) + "\n"
1854 out_string
+= "\t old:\t"
1855 out_string
+= GetSourceInformationForAddress(pr
.pr_old
) + "\n"
1857 out_string
+= "\t pru_flags:0x\t" + hex(pru
.pru_flags
) + "\n"
1858 out_string
+= "\t abort:\t"
1859 out_string
+= GetSourceInformationForAddress(pru
.pru_abort
) + "\n"
1860 out_string
+= "\t accept:\t"
1861 out_string
+= GetSourceInformationForAddress(pru
.pru_accept
) + "\n"
1862 out_string
+= "\t attach:\t"
1863 out_string
+= GetSourceInformationForAddress(pru
.pru_attach
) + "\n"
1864 out_string
+= "\t bind:\t"
1865 out_string
+= GetSourceInformationForAddress(pru
.pru_bind
) + "\n"
1866 out_string
+= "\t connect:\t"
1867 out_string
+= GetSourceInformationForAddress(pru
.pru_connect
) + "\n"
1868 out_string
+= "\t connect2:\t"
1869 out_string
+= GetSourceInformationForAddress(pru
.pru_connect2
) + "\n"
1870 out_string
+= "\t connectx:\t"
1871 out_string
+= GetSourceInformationForAddress(pru
.pru_connectx
) + "\n"
1872 out_string
+= "\t control:\t"
1873 out_string
+= GetSourceInformationForAddress(pru
.pru_control
) + "\n"
1874 out_string
+= "\t detach:\t"
1875 out_string
+= GetSourceInformationForAddress(pru
.pru_detach
) + "\n"
1876 out_string
+= "\t disconnect:\t"
1877 out_string
+= GetSourceInformationForAddress(pru
.pru_disconnect
) + "\n"
1878 out_string
+= "\t listen:\t"
1879 out_string
+= GetSourceInformationForAddress(pru
.pru_listen
) + "\n"
1880 out_string
+= "\t peeraddr:\t"
1881 out_string
+= GetSourceInformationForAddress(pru
.pru_peeraddr
) + "\n"
1882 out_string
+= "\t rcvd:\t"
1883 out_string
+= GetSourceInformationForAddress(pru
.pru_rcvd
) + "\n"
1884 out_string
+= "\t rcvoob:\t"
1885 out_string
+= GetSourceInformationForAddress(pru
.pru_rcvoob
) + "\n"
1886 out_string
+= "\t send:\t"
1887 out_string
+= GetSourceInformationForAddress(pru
.pru_send
) + "\n"
1888 out_string
+= "\t sense:\t"
1889 out_string
+= GetSourceInformationForAddress(pru
.pru_sense
) + "\n"
1890 out_string
+= "\t shutdown:\t"
1891 out_string
+= GetSourceInformationForAddress(pru
.pru_shutdown
) + "\n"
1892 out_string
+= "\t sockaddr:\t"
1893 out_string
+= GetSourceInformationForAddress(pru
.pru_sockaddr
) + "\n"
1894 out_string
+= "\t sopoll:\t"
1895 out_string
+= GetSourceInformationForAddress(pru
.pru_sopoll
) + "\n"
1896 out_string
+= "\t soreceive:\t"
1897 out_string
+= GetSourceInformationForAddress(pru
.pru_soreceive
) + "\n"
1898 out_string
+= "\t sosend:\t"
1899 out_string
+= GetSourceInformationForAddress(pru
.pru_sosend
) + "\n"
1900 pr
= pr
.pr_entry
.tqe_next
1901 dp
= dp
.dom_entry
.tqe_next
1904 # EndMacro: show_domains