|
| 1 | +set pagination off |
| 2 | +set print elements 0 |
| 3 | +set max-value-size unlimited |
| 4 | + |
| 5 | +# usage: shm_hist_search 0x7faf32f44900 |
| 6 | +# ... to search for SHM activity near an address of crash (latest -> oldest) |
| 7 | +define shm_hist_search |
| 8 | + |
| 9 | + set $off = (long)&((struct struct_hist *)0).list |
| 10 | + set $first_obj = (struct struct_hist *)((char *)shm_hist->objects->prev - $off) |
| 11 | + set $last_obj = (struct struct_hist *)((char *)shm_hist->objects->next - $off) |
| 12 | + set $seconds = ($last_obj->created - $first_obj->created) / 1000000 |
| 13 | + |
| 14 | + set $it = shm_hist->objects->next |
| 15 | + set $cnt = 0 |
| 16 | + set $tot = 0 |
| 17 | + set $hlen = shm_hist->len |
| 18 | + |
| 19 | + printf "OpenSIPS run time: %d hours, %d mins\n", *jiffies / 3600, (*jiffies % 3600) / 60 |
| 20 | + printf "SHM history objects: %d now, %d all time\n", shm_hist->len, shm_hist->total_obj |
| 21 | + printf "Oldest SHM history object: %d seconds ago\n", $seconds |
| 22 | + |
| 23 | + printf "Digging in history for SHM activity close to address: %p ...\n", ($arg0) |
| 24 | + |
| 25 | + while ($tot < $hlen && $cnt < 100) |
| 26 | + set $tot = $tot + 1 |
| 27 | + |
| 28 | + set $hist = (struct struct_hist *)((char *)$it - $off) |
| 29 | + set $p = $hist->obj |
| 30 | + |
| 31 | + if $p >= ($arg0) - 1000 && $p <= ($arg0) |
| 32 | + p $hist->obj |
| 33 | + p *$hist->actions |
| 34 | + set $cnt = $cnt + 1 |
| 35 | + end |
| 36 | + |
| 37 | + if $tot % 100 == 0 |
| 38 | + printf "%d objects analyzed so far ...\n", $tot |
| 39 | + end |
| 40 | + |
| 41 | + set $it = $it->next |
| 42 | + end |
| 43 | +end |
| 44 | + |
| 45 | +# usage: tcpcon_hist_search 0x7faf32f44900 |
| 46 | +# ... to search for the history of a given connection (latest -> oldest) |
| 47 | +define tcpcon_hist_search |
| 48 | + |
| 49 | + set $off = (long)&((struct struct_hist *)0).list |
| 50 | + set $first_obj = (struct struct_hist *)((char *)con_hist->objects->prev - $off) |
| 51 | + set $last_obj = (struct struct_hist *)((char *)con_hist->objects->next - $off) |
| 52 | + set $seconds = ($last_obj->created - $first_obj->created) / 1000000 |
| 53 | + |
| 54 | + set $it = con_hist->objects->next |
| 55 | + set $tot = 0 |
| 56 | + set $found = 0 |
| 57 | + |
| 58 | + printf "OpenSIPS run time: %d hours, %d mins\n", *jiffies / 3600, (*jiffies % 3600) / 60 |
| 59 | + printf "CON history objects: %d now, %d all time\n", con_hist->len, con_hist->total_obj |
| 60 | + printf "Oldest CON history object: %d seconds ago\n", $seconds |
| 61 | + |
| 62 | + printf "Digging in CON histories for connection: %p ...\n", ($arg0) |
| 63 | + |
| 64 | + while ((long)$it != (long)con_hist->objects && !$found) |
| 65 | + set $tot = $tot + 1 |
| 66 | + |
| 67 | + set $hist = (struct struct_hist *)((char *)$it - $off) |
| 68 | + set $con = (struct tcp_connection *)$hist->obj |
| 69 | + |
| 70 | + if $con == ($arg0) |
| 71 | + set $found = 1 |
| 72 | + |
| 73 | + printf "Found history for conn: %p\n", $con |
| 74 | + printf "Total actions: %d, max: %d (all shown below)\n", $hist->len, $hist->max_len |
| 75 | + printf "-------------------------------------------------\n" |
| 76 | + set $i = 0 |
| 77 | + while ($i < $hist->max_len) |
| 78 | + p $hist->actions[$i++] |
| 79 | + end |
| 80 | + |
| 81 | + return |
| 82 | + else |
| 83 | + if $tot % 100 == 0 |
| 84 | + printf "%d objects analyzed so far ...\n", $tot |
| 85 | + end |
| 86 | + end |
| 87 | + |
| 88 | + set $it = $it->next |
| 89 | + end |
| 90 | + |
| 91 | + if !$found |
| 92 | + printf "ERROR: Failed to locate history for conn %p !\n", ($arg0) |
| 93 | + end |
| 94 | +end |
0 commit comments