Print this page
9210 remove KMDB branch debugging support
9211 ::crregs could do with cr2/cr3 support
9209 ::ttrace should be able to filter by thread
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Yuri Pankov <yuripv@yuripv.net>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c
          +++ new/usr/src/cmd/mdb/common/kmdb/kmdb_kvm.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2013 by Delphix. All rights reserved.
       24 + *
       25 + * Copyright 2018 Joyent, Inc.
  24   26   */
  25   27  
  26   28  #include <kmdb/kmdb_kvm.h>
  27   29  #include <kmdb/kvm.h>
  28   30  #include <kmdb/kmdb_kdi.h>
  29   31  #include <kmdb/kmdb_promif.h>
  30   32  #include <kmdb/kmdb_module.h>
  31   33  #include <kmdb/kmdb_asmutil.h>
  32   34  #include <mdb/mdb_types.h>
  33   35  #include <mdb/mdb_conf.h>
↓ open down ↓ 508 lines elided ↑ open up ↑
 542  544          if (!first && msg != NULL)
 543  545                  mdb_printf("\n");
 544  546  
 545  547          return (n);
 546  548  }
 547  549  
 548  550  /*ARGSUSED*/
 549  551  static int
 550  552  kmt_status_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 551  553  {
 552      -        kmt_data_t *kmt = mdb.m_target->t_data;
 553  554          struct utsname uts;
 554  555          char uuid[37];
 555  556          kreg_t tt;
 556  557  
 557  558          if (mdb_tgt_readsym(mdb.m_target, MDB_TGT_AS_VIRT, &uts, sizeof (uts),
 558  559              "unix", "utsname") != sizeof (uts)) {
 559  560                  warn("failed to read 'utsname' struct from kernel\n");
 560  561                  bzero(&uts, sizeof (uts));
 561  562                  (void) strcpy(uts.nodename, "unknown machine");
 562  563          }
↓ open down ↓ 8 lines elided ↑ open up ↑
 571  572              "genunix", "dump_osimage_uuid") != sizeof (uuid)) {
 572  573                  warn("failed to read 'dump_osimage_uuid' string from kernel\n");
 573  574                  (void) strcpy(uuid, "(error)");
 574  575          } else if (*uuid == '\0') {
 575  576                  (void) strcpy(uuid, "(not set)");
 576  577          } else if (uuid[36] != '\0') {
 577  578                  (void) strcpy(uuid, "(invalid)");
 578  579          }
 579  580          mdb_printf("image uuid: %s\n", uuid);
 580  581  
 581      -        if (kmt->kmt_cpu != NULL) {
 582      -                mdb_printf("CPU-specific support: %s\n",
 583      -                    kmt_cpu_name(kmt->kmt_cpu));
 584      -        }
 585      -
 586  582          mdb_printf("DTrace state: %s\n", (kmdb_kdi_dtrace_get_state() ==
 587  583              KDI_DTSTATE_DTRACE_ACTIVE ? "active (debugger breakpoints cannot "
 588  584              "be armed)" : "inactive"));
 589  585  
 590  586          (void) kmdb_dpi_get_register("tt", &tt);
 591  587          mdb_printf("stopped on: %s\n", kmt_trapname(tt));
 592  588  
 593  589          (void) kmt_dmod_status("pending dmod loads:", KMDB_MC_STATE_LOADING);
 594  590          (void) kmt_dmod_status("pending dmod unloads:",
 595  591              KMDB_MC_STATE_UNLOADING);
↓ open down ↓ 1789 lines elided ↑ open up ↑
2385 2381                  pkm = mdb_list_prev(km);
2386 2382                  mdb_free(km, sizeof (kmt_module_t));
2387 2383          }
2388 2384  
2389 2385          if (!kmt_defbp_lock)
2390 2386                  kmt_defbp_destroy_all();
2391 2387  
2392 2388          if (kmt->kmt_trapmap != NULL)
2393 2389                  mdb_free(kmt->kmt_trapmap, BT_SIZEOFMAP(kmt->kmt_trapmax));
2394 2390  
2395      -        if (kmt->kmt_cpu != NULL)
2396      -                kmt_cpu_destroy(kmt->kmt_cpu);
2397      -
2398 2391          if (kmt != NULL)
2399 2392                  mdb_free(kmt, sizeof (kmt_data_t));
2400 2393  }
2401 2394  
2402 2395  static const mdb_tgt_ops_t kmt_ops = {
2403 2396          kmt_setflags,                           /* t_setflags */
2404 2397          (int (*)()) mdb_tgt_notsup,             /* t_setcontext */
2405 2398          kmt_activate,                           /* t_activate */
2406 2399          (void (*)()) mdb_tgt_nop,               /* t_deactivate */
2407 2400          kmt_periodic,                           /* t_periodic */
↓ open down ↓ 20 lines elided ↑ open up ↑
2428 2421          kmt_mapping_iter,                       /* t_mapping_iter */
2429 2422          kmt_object_iter,                        /* t_object_iter */
2430 2423          kmt_addr_to_map,                        /* t_addr_to_map */
2431 2424          kmt_name_to_map,                        /* t_name_to_map */
2432 2425          kmt_addr_to_ctf,                        /* t_addr_to_ctf */
2433 2426          kmt_name_to_ctf,                        /* t_name_to_ctf */
2434 2427          kmt_status,                             /* t_status */
2435 2428          (int (*)()) mdb_tgt_notsup,             /* t_run */
2436 2429          kmt_step,                               /* t_step */
2437 2430          kmt_step_out,                           /* t_step_out */
2438      -        kmt_step_branch,                        /* t_step_branch */
2439 2431          kmt_next,                               /* t_next */
2440 2432          kmt_continue,                           /* t_cont */
2441 2433          (int (*)()) mdb_tgt_notsup,             /* t_signal */
2442 2434          kmt_add_vbrkpt,                         /* t_add_vbrkpt */
2443 2435          kmt_add_sbrkpt,                         /* t_add_sbrkpt */
2444 2436          kmt_add_pwapt,                          /* t_add_pwapt */
2445 2437          kmt_add_vwapt,                          /* t_add_vwapt */
2446 2438          kmt_add_iowapt,                         /* t_add_iowapt */
2447 2439          (int (*)()) mdb_tgt_null,               /* t_add_sysenter */
2448 2440          (int (*)()) mdb_tgt_null,               /* t_add_sysexit */
↓ open down ↓ 48 lines elided ↑ open up ↑
2497 2489                   * and consequently the deferred breakpoint enabling mechanism
2498 2490                   * wasn't activated.  Activate it now, and then try to activate
2499 2491                   * the deferred breakpoints.  We do this so that we can catch
2500 2492                   * the ones which may apply to modules that have been loaded
2501 2493                   * while they were waiting for DTrace to deactivate.
2502 2494                   */
2503 2495                  (void) kmt_defbp_activate(t);
2504 2496                  (void) mdb_tgt_sespec_activate_all(t);
2505 2497          }
2506 2498  
2507      -        if (kmt->kmt_cpu_retry && ((kmt->kmt_cpu = kmt_cpu_create(t)) !=
2508      -            NULL || errno != EAGAIN))
2509      -                kmt->kmt_cpu_retry = FALSE;
2510      -
2511 2499          (void) mdb_tgt_status(t, &t->t_status);
2512 2500  }
2513 2501  
2514 2502  /*
2515 2503   * This routine executes while the kernel is running.
2516 2504   */
2517 2505  /*ARGSUSED*/
2518 2506  int
2519 2507  kmdb_kvm_create(mdb_tgt_t *t, int argc, const char *argv[])
2520 2508  {
↓ open down ↓ 8 lines elided ↑ open up ↑
2529 2517          t->t_flags |= MDB_TGT_F_RDWR;   /* kmdb is always r/w */
2530 2518  
2531 2519          (void) mdb_nv_insert(&mdb.m_nv, "cpuid", &kmt_cpuid_disc, 0,
2532 2520              MDB_NV_PERSIST | MDB_NV_RDONLY);
2533 2521  
2534 2522          (void) mdb_nv_create(&kmt->kmt_modules, UM_SLEEP);
2535 2523  
2536 2524          kmt_init_isadep(t);
2537 2525  
2538 2526          kmt->kmt_symavail = FALSE;
2539      -        kmt->kmt_cpu_retry = TRUE;
2540 2527  
2541 2528          bzero(&kmt_defbp_list, sizeof (mdb_list_t));
2542 2529  
2543 2530          return (0);
2544 2531  
2545 2532  create_err:
2546 2533          kmt_destroy(t);
2547 2534  
2548 2535          return (-1);
2549 2536  }
↓ open down ↓ 39 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX