From owner-svn-src-head@FreeBSD.ORG Mon Nov 12 00:30:41 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 12B34FEC; Mon, 12 Nov 2012 00:30:41 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id ED04E8FC08; Mon, 12 Nov 2012 00:30:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAC0Uecs024606; Mon, 12 Nov 2012 00:30:40 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAC0UeS9024605; Mon, 12 Nov 2012 00:30:40 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201211120030.qAC0UeS9024605@svn.freebsd.org> From: Attilio Rao Date: Mon, 12 Nov 2012 00:30:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242903 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Nov 2012 00:30:41 -0000 Author: attilio Date: Mon Nov 12 00:30:40 2012 New Revision: 242903 URL: http://svnweb.freebsd.org/changeset/base/242903 Log: Fix DDB command "show map XXX": - Check that an argument is always available, otherwise current map printing before to recurse is garbage. - Spit out a message if an argument is not provided. - Remove unread nlines variable. - Use an explicit recursive function, disassociated from the DB_SHOW_COMMAND() body, in order to make clear prototype and recursion of the above mentioned function. The code results now much less obscure. Submitted by: gianni Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Sun Nov 11 23:29:45 2012 (r242902) +++ head/sys/vm/vm_map.c Mon Nov 12 00:30:40 2012 (r242903) @@ -3975,32 +3975,20 @@ vm_map_lookup_done(vm_map_t map, vm_map_ #include -/* - * vm_map_print: [ debug ] - */ -DB_SHOW_COMMAND(map, vm_map_print) +static void +vm_map_print(vm_map_t map) { - static int nlines; - /* XXX convert args. */ - vm_map_t map = (vm_map_t)addr; - boolean_t full = have_addr; - vm_map_entry_t entry; db_iprintf("Task map %p: pmap=%p, nentries=%d, version=%u\n", (void *)map, (void *)map->pmap, map->nentries, map->timestamp); - nlines++; - - if (!full && db_indent) - return; db_indent += 2; for (entry = map->header.next; entry != &map->header; entry = entry->next) { db_iprintf("map entry %p: start=%p, end=%p\n", (void *)entry, (void *)entry->start, (void *)entry->end); - nlines++; { static char *inheritance_name[4] = {"share", "copy", "none", "donate_copy"}; @@ -4016,14 +4004,11 @@ DB_SHOW_COMMAND(map, vm_map_print) db_printf(", share=%p, offset=0x%jx\n", (void *)entry->object.sub_map, (uintmax_t)entry->offset); - nlines++; if ((entry->prev == &map->header) || (entry->prev->object.sub_map != entry->object.sub_map)) { db_indent += 2; - vm_map_print((db_expr_t)(intptr_t) - entry->object.sub_map, - full, 0, (char *)0); + vm_map_print((vm_map_t)entry->object.sub_map); db_indent -= 2; } } else { @@ -4040,7 +4025,6 @@ DB_SHOW_COMMAND(map, vm_map_print) db_printf(", copy (%s)", (entry->eflags & MAP_ENTRY_NEEDS_COPY) ? "needed" : "done"); db_printf("\n"); - nlines++; if ((entry->prev == &map->header) || (entry->prev->object.vm_object != @@ -4048,17 +4032,23 @@ DB_SHOW_COMMAND(map, vm_map_print) db_indent += 2; vm_object_print((db_expr_t)(intptr_t) entry->object.vm_object, - full, 0, (char *)0); - nlines += 4; + 1, 0, (char *)0); db_indent -= 2; } } } db_indent -= 2; - if (db_indent == 0) - nlines = 0; } +DB_SHOW_COMMAND(map, map) +{ + + if (!have_addr) { + db_printf("usage: show map \n"); + return; + } + vm_map_print((vm_map_t)addr); +} DB_SHOW_COMMAND(procvm, procvm) { @@ -4074,7 +4064,7 @@ DB_SHOW_COMMAND(procvm, procvm) (void *)p, (void *)p->p_vmspace, (void *)&p->p_vmspace->vm_map, (void *)vmspace_pmap(p->p_vmspace)); - vm_map_print((db_expr_t)(intptr_t)&p->p_vmspace->vm_map, 1, 0, NULL); + vm_map_print((vm_map_t)&p->p_vmspace->vm_map); } #endif /* DDB */