* Lookup a thread based on a db expression address. We assume that the * address was parsed in hexadecimal. We reparse the address in decimal * first and try to treat it as a thread ID to find an associated thread. * If that fails and check_pid is true, we treat the decimal value as a * PID. If that matches a process, we return the first thread in that * process. Otherwise, we treat the a
| 110 | * process. Otherwise, we treat the addr as a pointer to a thread. |
| 111 | */ |
| 112 | struct thread * |
| 113 | db_lookup_thread(db_expr_t addr, bool check_pid) |
| 114 | { |
| 115 | struct thread *td; |
| 116 | db_expr_t decaddr; |
| 117 | |
| 118 | /* |
| 119 | * If the parsed address was not a valid decimal expression, |
| 120 | * assume it is a thread pointer. |
| 121 | */ |
| 122 | decaddr = db_hex2dec(addr); |
| 123 | if (decaddr == -1) |
| 124 | return ((struct thread *)addr); |
| 125 | |
| 126 | td = kdb_thr_lookup(decaddr); |
| 127 | if (td != NULL) |
| 128 | return (td); |
| 129 | if (check_pid) { |
| 130 | td = kdb_thr_from_pid(decaddr); |
| 131 | if (td != NULL) |
| 132 | return (td); |
| 133 | } |
| 134 | return ((struct thread *)addr); |
| 135 | } |
| 136 | |
| 137 | /* |
| 138 | * Lookup a process based on a db expression address. We assume that the |
no test coverage detected