Dave Barach | 17c4531 | 2020-06-23 17:36:12 -0400 | [diff] [blame] | 1 | # Copyright (c) 2020 Cisco and/or its affiliates. |
| 2 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | # you may not use this file except in compliance with the License. |
| 4 | # You may obtain a copy of the License at: |
| 5 | # |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # |
| 8 | # Unless required by applicable law or agreed to in writing, software |
| 9 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | # See the License for the specific language governing permissions and |
| 12 | # limitations under the License. |
| 13 | |
| 14 | echo Loading vpp functions...\n |
| 15 | |
| 16 | echo Load vl |
| 17 | # vl, aka vec_len (x) |
| 18 | # The vector length is 8 bytes before the vector pointer |
| 19 | define vl |
| 20 | echo vec_len ($arg0): |
| 21 | p/d ((u32 *)((u8 *)(($arg0))-8))[0] |
| 22 | end |
| 23 | document vl |
| 24 | Usage: vl <vector> |
| 25 | Prints the length of a vector |
| 26 | end |
| 27 | |
| 28 | echo Load pe\n |
| 29 | # pe, aka pool_elts; the number of elements in the vector, minus the |
| 30 | # length of the free element vector. The free element vector is at |
| 31 | # offset -40 from the user pointer |
| 32 | define pe |
| 33 | echo pool_elts ($arg0): |
| 34 | p/d ((((u32 *)((u8 *)(($arg0))-8))[0]) - (((u32 *)((u8 *)(($arg0))-40))[0])) |
| 35 | end |
| 36 | document pe |
| 37 | Usage: pe <pool> |
| 38 | Prints the number of active elements in a pool |
| 39 | end |
| 40 | |
| 41 | echo Load pifi\n |
| 42 | # pifi, aka pool_is_free_index. Print 1 if the pool index is free, 0 if |
| 43 | # it's in-use. |
| 44 | # |
| 45 | # If the index is less than the pool vector |
| 46 | # length, see if the indicated bit in the indicated bitmap word is set. |
| 47 | # Otherwise, the index is not in use |
| 48 | # |
| 49 | # If you wonder why you might want a gdb macro to work this out when looking |
| 50 | # at a core file, just look at the expression... |
| 51 | |
| 52 | define pifi |
| 53 | echo pool_is_free_index ($arg0, $arg1) |
| 54 | p ($arg1 < (((u32 *)((u8 *)(($arg0))-8))[0])) ? (((1ULL<<(($arg1)%64)) & \ |
| 55 | ((u64 **)(((u8 *)($arg0)-48)))[0][($arg1)/64]) !=0) : 1 |
| 56 | end |
| 57 | document pifi |
| 58 | Usage: pifi <pool-pointer> <index> |
| 59 | Print 1 if a specific pool index is free (or out of range), 0 if it's in-use |
| 60 | end |
| 61 | |
| 62 | echo Load node_name_from_index\n |
| 63 | define node_name_from_index |
| 64 | p vlib_global_main.node_main.nodes[$arg0].name |
| 65 | end |
| 66 | document node_name_from_index |
| 67 | Usage: node_name_from_index <index> |
| 68 | Print node name given a node index (or node runtime index) |
| 69 | end |
| 70 | |
| 71 | echo Load vnet_buffer_opaque\n |
| 72 | define vnet_buffer_opaque |
| 73 | p ((vnet_buffer_opaque_t *)(&((vlib_buffer_t *)($arg0))->opaque[0]))[0] |
| 74 | end |
| 75 | document vnet_buffer_opaque |
| 76 | Usage: vnet_buffer_opaque <vlib_buffer_t pointer> |
| 77 | Print the vnet buffer opaque given a vlib_buffer_t |
| 78 | end |
| 79 | |
| 80 | echo Load vnet_buffer_opaque2\n |
| 81 | define vnet_buffer_opaque2 |
| 82 | p ((vnet_buffer_opaque2_t *)(&((vlib_buffer_t *)($arg0))->opaque2[0]))[0] |
| 83 | end |
| 84 | document vnet_buffer_opaque2 |
| 85 | Usage: vnet_buffer_opaque2 <vlib_buffer_t pointer> |
| 86 | Print the vnet buffer opaque2 given a vlib_buffer_t |
| 87 | end |
| 88 | |
| 89 | echo Load bitmap_get\n |
| 90 | define bitmap_get |
| 91 | echo bitmap get ($arg0, $arg1): |
| 92 | p ($arg1/64 < ((u32 *)((u8 *)($arg0)-8))[0]) ? (((1ULL<<(($arg1)%64)) & \ |
| 93 | ((u64 *)(($arg0)))[($arg1)/64]) != 0) : 0 |
| 94 | end |
| 95 | document bitmap_get |
| 96 | Usage: bitmap_get <bitmap> <index> |
| 97 | Print 1 if a specific bitmap index is set, 0 if it's not set or out of range |
| 98 | end |
| 99 | |
| 100 | echo Done loading vpp functions...\n |