From owner-svn-src-head@freebsd.org Sun Sep 25 18:39:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F744BE9573; Sun, 25 Sep 2016 18:39:25 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 36B9DAF0; Sun, 25 Sep 2016 18:39:25 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8PIdOaT050381; Sun, 25 Sep 2016 18:39:24 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8PIdO7t050380; Sun, 25 Sep 2016 18:39:24 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201609251839.u8PIdO7t050380@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Sun, 25 Sep 2016 18:39:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306319 - head/sys/i386/i386 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.23 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: Sun, 25 Sep 2016 18:39:25 -0000 Author: bde Date: Sun Sep 25 18:39:24 2016 New Revision: 306319 URL: https://svnweb.freebsd.org/changeset/base/306319 Log: Minor fixes for 160-bit disassembly: (1) Print the default segment %ss before adresses relative to %bp. This is too cluttered for me, but so is printing some other default prefixes, and this is a reasonable reminder that %ss is quite likely to be different from %ds in 16-bit mode. db_disasm still handles prefixes poorly, by trying to discard redundant ones. This loses information, and sometimes the result is wrong or misleading. Clean up nearby initializations and dead code. (2) Fix decoding of operand and address size prefixes in 16-bit mode. They reverse the default in all modes. Obtained from: (1) is partly from r1.4 (2003/11/08) in DFlyBSD (?) Modified: head/sys/i386/i386/db_disasm.c Modified: head/sys/i386/i386/db_disasm.c ============================================================================== --- head/sys/i386/i386/db_disasm.c Sun Sep 25 18:29:02 2016 (r306318) +++ head/sys/i386/i386/db_disasm.c Sun Sep 25 18:39:24 2016 (r306319) @@ -884,6 +884,7 @@ struct i_addr { const char * base; const char * index; int ss; + bool defss; /* set if %ss is the default segment */ }; static const char * const db_index_reg_16[8] = { @@ -955,10 +956,12 @@ db_read_address(loc, short_addr, regmodr } addrp->is_reg = FALSE; addrp->index = NULL; + addrp->ss = 0; + addrp->defss = FALSE; if (short_addr) { - addrp->index = NULL; - addrp->ss = 0; + if (rm == 2 || rm == 3 || (rm == 6 && mod != 0)) + addrp->defss = TRUE; switch (mod) { case 0: if (rm == 6) { @@ -985,7 +988,7 @@ db_read_address(loc, short_addr, regmodr } } else { - if (mod != 3 && rm == 4) { + if (rm == 4) { get_value_inc(sib, loc, 1, FALSE); rm = sib_base(sib); index = sib_index(sib); @@ -1036,6 +1039,9 @@ db_print_address(seg, size, addrp) if (seg) { db_printf("%s:", seg); } + else if (addrp->defss) { + db_printf("%%ss:"); + } db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY); if (addrp->base != NULL || addrp->index != NULL) { @@ -1189,11 +1195,11 @@ db_disasm(db_addr_t loc, bool altfmt) prefix = TRUE; do { switch (inst) { - case 0x66: /* data16 */ - size = WORD; + case 0x66: + size = (altfmt ? LONG : WORD); break; case 0x67: - short_addr = TRUE; + short_addr = !altfmt; break; case 0x26: seg = "%es";