| 144 | } |
| 145 | |
| 146 | static void |
| 147 | db_putc(int c) |
| 148 | { |
| 149 | |
| 150 | /* |
| 151 | * If not in the debugger or the user requests it, output data to |
| 152 | * both the console and the message buffer. |
| 153 | */ |
| 154 | if (!kdb_active || ddb_use_printf) { |
| 155 | printf("%c", c); |
| 156 | if (!kdb_active) |
| 157 | return; |
| 158 | if (c == '\r' || c == '\n') |
| 159 | db_check_interrupt(); |
| 160 | if (c == '\n' && db_maxlines > 0) { |
| 161 | db_newlines++; |
| 162 | if (db_newlines >= db_maxlines) |
| 163 | db_pager(); |
| 164 | } |
| 165 | return; |
| 166 | } |
| 167 | |
| 168 | /* Otherwise, output data directly to the console. */ |
| 169 | if (c > ' ' && c <= '~') { |
| 170 | /* |
| 171 | * Printing character. |
| 172 | * If we have spaces to print, print them first. |
| 173 | * Use tabs if possible. |
| 174 | */ |
| 175 | db_force_whitespace(); |
| 176 | cnputc(c); |
| 177 | db_capture_writech(c); |
| 178 | db_output_position++; |
| 179 | db_last_non_space = db_output_position; |
| 180 | } |
| 181 | else if (c == '\n') { |
| 182 | /* Newline */ |
| 183 | cnputc(c); |
| 184 | db_capture_writech(c); |
| 185 | db_output_position = 0; |
| 186 | db_last_non_space = 0; |
| 187 | db_check_interrupt(); |
| 188 | if (db_maxlines > 0) { |
| 189 | db_newlines++; |
| 190 | if (db_newlines >= db_maxlines) |
| 191 | db_pager(); |
| 192 | } |
| 193 | } |
| 194 | else if (c == '\r') { |
| 195 | /* Return */ |
| 196 | cnputc(c); |
| 197 | db_capture_writech(c); |
| 198 | db_output_position = 0; |
| 199 | db_last_non_space = 0; |
| 200 | db_check_interrupt(); |
| 201 | } |
| 202 | else if (c == '\t') { |
| 203 | /* assume tabs every 8 positions */ |
no test coverage detected