Skip to content

Commit

Permalink
Merge "Add gdb macro to dump flow entries ."
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jan 15, 2017
2 parents d431a82 + 36ea7e6 commit e2e2412
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/vnsw/agent/gdb/agent_db.py
Expand Up @@ -62,6 +62,24 @@ def print_db_entries(db_table, print_fn = print_db_entry, filter_fn = default_fi
except StopIteration:
pass

def print_flow_entry(entry):
print(str(entry))

def print_flow_entry_map(flow_table):
table_ptr = gdb.parse_and_eval('(FlowTable *)' + str(flow_table))
flow_map = StdMapPrinter('flow_entry_map_', table_ptr['flow_entry_map_'])
it = flow_map.children()
try:
while (it):
entry = next(it)[1]
print_flow_entry(entry)
except StopIteration:
pass

def dump_flow_entries():
f_table = gdb.parse_and_eval('Agent::singleton_->pkt_->flow_table_.px')
print_flow_entry_map(f_table)

def print_vrf_entry(entry):
vrf = entry.cast(gdb.lookup_type('VrfEntry'))
print(str(vrf.address) + " %-20s idx=%-4d ref_count=%-4d flags=%-4d rt_db=" % ((vrf['name_']), vrf['id_'], vrf['refcount_']['my_storage']['my_value'], vrf['flags']) + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET4_UNICAST'))]) + " mcrt_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET4_MULTICAST'))]) + " evpn_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::EVPN'))]) + " bridge_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::BRIDGE'))]) + " v6_rt_db=" + str(vrf['rt_table_db_'][int(gdb.parse_and_eval('Agent::INET6_UNICAST'))]))
Expand Down
14 changes: 14 additions & 0 deletions src/vnsw/agent/gdb/agent_printer/printers.py
Expand Up @@ -135,6 +135,16 @@ def to_string (self):

return '<%s nh=%-6d sip=%-15s dip=%-15s proto=%-3d sport=%-5d dport=%-5d>' % (family, nh, sip, dip, proto, sport, dport)

class FlowEntryPrinter:
"Print TBB atomic varaiable of some kind"
def __init__ (self, typename, val):
self.typename = typename
self.val = val

def to_string (self):
return 'FlowEntryAddr %s Source_vn %s Dest_vn %s Packets %d Bytes %d Flags %d SetupTime %d ModifiedTime %d' % (str(self.val.address), self.val['data_']['source_vn'],
self.val['data_']['dest_vn'], self.val['stats_']['packets'], self.val['stats_']['bytes'], self.val['flags_'], self.val['stats_']['setup_time'], self.val['stats_']['last_modified_time'])

class IpPrinter:
"Print TBB atomic varaiable of some kind"
def __init__ (self, typename, val):
Expand Down Expand Up @@ -214,6 +224,9 @@ def get_basic_type(type):
if type.code == gdb.TYPE_CODE_REF:
type = type.target ()

if type.code == gdb.TYPE_CODE_PTR:
type = type.target ()

# Get the unqualified type, stripped of typedefs.
type = type.unqualified ().strip_typedefs ()

Expand Down Expand Up @@ -267,6 +280,7 @@ def build_agent_dictionary ():
# tbb objects requiring pretty-printing.
# In order from:
agent_printer.add('FlowKey', FlowKeyPrinter)
agent_printer.add('FlowEntry', FlowEntryPrinter)
agent_printer.add('boost::asio::ip::address', IpPrinter)
agent_printer.add('boost::asio::ip::address_v4', Ipv4Printer)
agent_printer.add('tbb::atomic', TbbAtomicIntPrinter)
Expand Down

0 comments on commit e2e2412

Please sign in to comment.