db_print.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* $OpenBSD: db_print.c,v 1.15 2015/03/14 03:38:46 jsg Exp $ */
  2. /* $NetBSD: db_print.c,v 1.5 1996/02/05 01:57:11 christos Exp $ */
  3. /*
  4. * Mach Operating System
  5. * Copyright (c) 1993,1992,1991,1990 Carnegie Mellon University
  6. * All Rights Reserved.
  7. *
  8. * Permission to use, copy, modify and distribute this software and its
  9. * documentation is hereby granted, provided that both the copyright
  10. * notice and this permission notice appear in all copies of the
  11. * software, derivative works or modified versions, and any portions
  12. * thereof, and that both notices appear in supporting documentation.
  13. *
  14. * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  15. * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  16. * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  17. *
  18. * Carnegie Mellon requests users of this software to return to
  19. *
  20. * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
  21. * School of Computer Science
  22. * Carnegie Mellon University
  23. * Pittsburgh PA 15213-3890
  24. *
  25. * any improvements or extensions that they make and grant Carnegie Mellon
  26. * the rights to redistribute these changes.
  27. *
  28. * Author: David B. Golub, Carnegie Mellon University
  29. * Date: 7/90
  30. */
  31. /*
  32. * Miscellaneous printing.
  33. */
  34. #include <sys/param.h>
  35. #include <sys/systm.h>
  36. #include <machine/db_machdep.h>
  37. #include <ddb/db_variables.h>
  38. #include <ddb/db_sym.h>
  39. #include <ddb/db_output.h>
  40. #include <ddb/db_extern.h>
  41. /*ARGSUSED*/
  42. void
  43. db_show_regs(db_expr_t addr, int have_addr, db_expr_t count, char *modif)
  44. {
  45. struct db_variable *regp;
  46. db_expr_t value, offset;
  47. char * name;
  48. char tmpfmt[28];
  49. for (regp = db_regs; regp < db_eregs; regp++) {
  50. db_read_variable(regp, &value);
  51. db_printf("%-12s%s", regp->name, db_format(tmpfmt, sizeof tmpfmt,
  52. (long)value, DB_FORMAT_N, 1, sizeof(long) * 3));
  53. db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset);
  54. if (name != 0 && offset <= db_maxoff && offset != value) {
  55. db_printf("\t%s", name);
  56. if (offset != 0)
  57. db_printf("+%s", db_format(tmpfmt, sizeof tmpfmt,
  58. (long)offset, DB_FORMAT_R, 1, 0));
  59. }
  60. db_printf("\n");
  61. }
  62. db_print_loc_and_inst(PC_REGS(DDB_REGS));
  63. }