Project

General

Profile

Actions

Bug #5998

closed

mdb_ctf_vread fails in dcmds run via mdb_pwalk_dcmd

Added by Gordon Ross over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
mdb - modular debugger
Start date:
2015-06-11
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

This is essentially the same problem as #3473 but with mdb_pwalk_dcmd, where #3473 fixed mdb_pwalk.

The manifestation was seen with the "smbsrv" mdb module after modifications to use mdb_ctf_vread.
The dcmds implement with mdb_pwalk_dcmd fail like this:

$ mdb -L $ROOT/usr/lib/mdb/proc:/usr/lib/mdb/proc /var/smb/core.3470 
Loading modules: [ libumem.so.1 libfksmbsrv.so.1 libcmdutils.so.1 libc.so.1 libavl.so.1 libtopo.so.1 libuutil.so.1 libnvpair.so.1 ld.so.1 ]
> ::smblist                           
mdb: couldn't find ctf data for type mdb_smb_server_t in mdb module libcmdutils.so.1
mdb: failed to read smb_server at 82ac000: No type information available for that name


Related issues

Related to illumos gate - Bug #3473: mdb_get_module() returns wrong moduleClosedChristopher Siden2013-01-15

Actions
Actions #1

Updated by Gordon Ross over 8 years ago

The fix for #3473 added a check for the f_cbactive flag on the "top" (deepest) walker.
That flag is set by mdb_pwalk when it invokes the call-back function.

By comparison, mdb_pwalk_dcmd calls walk_dcmd, which calls
mdb_call_idcmd. That last is essentially our "call-back" function
corresponding to the call back in mdb_pwalk / walk_step.
At that point, we're no longer in walker module code and should
set f_cbactive there like mdb_pwalk does. That fixes it for me.

The fix is small, so here it is:

diff --git a/usr/src/cmd/mdb/common/mdb/mdb_modapi.c b/usr/src/cmd/mdb/common/mdb/mdb_modapi.c
index a95a866..9f6cd92 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_modapi.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_modapi.c
@@ -580,8 +580,12 @@ mdb_walk(const char *name, mdb_walk_cb_t func, void *data)
 static int
 walk_dcmd(uintptr_t addr, const void *ignored, dcmd_walk_arg_t *dwp)
 {
-    int status = mdb_call_idcmd(dwp->dw_dcmd, addr, 1, dwp->dw_flags,
+    int status;
+
+    mdb.m_frame->f_cbactive = B_TRUE;
+    status = mdb_call_idcmd(dwp->dw_dcmd, addr, 1, dwp->dw_flags,
         &dwp->dw_argv, NULL, NULL);
+    mdb.m_frame->f_cbactive = B_FALSE;

     if (status == DCMD_USAGE || status == DCMD_ABORT)
         return (WALK_ERR);

Actions #2

Updated by Gordon Ross over 8 years ago

  • Status changed from New to In Progress
Actions #3

Updated by Gordon Ross over 8 years ago

BTW, this is doing essentially the same thing as mdb_modapi.c:pwalk_step
http://src.illumos.org/source/xref/illumos-gate/usr/src/cmd/mdb/common/mdb/mdb_modapi.c#537

Actions #4

Updated by Gordon Ross over 8 years ago

  • Related to Bug #3473: mdb_get_module() returns wrong module added
Actions #5

Updated by Electric Monk about 8 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 315fecc41c08848bacfc1ee331b9693077b057ff

commit  315fecc41c08848bacfc1ee331b9693077b057ff
Author: Gordon Ross <gwr@nexenta.com>
Date:   2015-10-03T22:09:30.000Z

    5998 mdb_ctf_vread fails in dcmds run via mdb_pwalk_dcmd
    Reviewed by: Josef Sipek <jeffpc@josefsipek.net>
    Reviewed by: Matthew Ahrens <mahrens@delphix.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

Actions

Also available in: Atom PDF