< prev index next >

src/share/vm/compiler/disassembler.cpp

Print this page
rev 8113 : 8076475: Misuses of strncpy/strncat
Summary: Various small fixes around strncpy and strncat
Reviewed-by: dsamersoff


 283     tty->print_cr("combined options: %s", options());
 284   }
 285 }
 286 
 287 address decode_env::handle_event(const char* event, address arg) {
 288   if (match(event, "insn")) {
 289     start_insn(arg);
 290   } else if (match(event, "/insn")) {
 291     end_insn(arg);
 292   } else if (match(event, "addr")) {
 293     if (arg != NULL) {
 294       print_address(arg);
 295       return arg;
 296     }
 297   } else if (match(event, "mach")) {
 298     static char buffer[32] = { 0, };
 299     if (strcmp(buffer, (const char*)arg) != 0 ||
 300         strlen((const char*)arg) > sizeof(buffer) - 1) {
 301       // Only print this when the mach changes
 302       strncpy(buffer, (const char*)arg, sizeof(buffer) - 1);

 303       output()->print_cr("[Disassembling for mach='%s']", arg);
 304     }
 305   } else if (match(event, "format bytes-per-line")) {
 306     _bytes_per_line = (int) (intptr_t) arg;
 307   } else {
 308     // ignore unrecognized markup
 309   }
 310   return NULL;
 311 }
 312 
 313 // called by the disassembler to print out jump targets and data addresses
 314 void decode_env::print_address(address adr) {
 315   outputStream* st = _output;
 316 
 317   if (adr == NULL) {
 318     st->print("NULL");
 319     return;
 320   }
 321 
 322   int small_num = (int)(intptr_t)adr;




 283     tty->print_cr("combined options: %s", options());
 284   }
 285 }
 286 
 287 address decode_env::handle_event(const char* event, address arg) {
 288   if (match(event, "insn")) {
 289     start_insn(arg);
 290   } else if (match(event, "/insn")) {
 291     end_insn(arg);
 292   } else if (match(event, "addr")) {
 293     if (arg != NULL) {
 294       print_address(arg);
 295       return arg;
 296     }
 297   } else if (match(event, "mach")) {
 298     static char buffer[32] = { 0, };
 299     if (strcmp(buffer, (const char*)arg) != 0 ||
 300         strlen((const char*)arg) > sizeof(buffer) - 1) {
 301       // Only print this when the mach changes
 302       strncpy(buffer, (const char*)arg, sizeof(buffer) - 1);
 303       buffer[sizeof(buffer) - 1] = '\0';
 304       output()->print_cr("[Disassembling for mach='%s']", arg);
 305     }
 306   } else if (match(event, "format bytes-per-line")) {
 307     _bytes_per_line = (int) (intptr_t) arg;
 308   } else {
 309     // ignore unrecognized markup
 310   }
 311   return NULL;
 312 }
 313 
 314 // called by the disassembler to print out jump targets and data addresses
 315 void decode_env::print_address(address adr) {
 316   outputStream* st = _output;
 317 
 318   if (adr == NULL) {
 319     st->print("NULL");
 320     return;
 321   }
 322 
 323   int small_num = (int)(intptr_t)adr;


< prev index next >