From owner-svn-src-all@freebsd.org Wed Dec 14 00:18:13 2016 Return-Path: Delivered-To: svn-src-all@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 A97D7C76F02; Wed, 14 Dec 2016 00:18:13 +0000 (UTC) (envelope-from jhb@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 5F84A1275; Wed, 14 Dec 2016 00:18:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBE0IC26004687; Wed, 14 Dec 2016 00:18:12 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBE0ICrE004686; Wed, 14 Dec 2016 00:18:12 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201612140018.uBE0ICrE004686@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 14 Dec 2016 00:18:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310045 - head/sys/ddb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Dec 2016 00:18:13 -0000 Author: jhb Date: Wed Dec 14 00:18:12 2016 New Revision: 310045 URL: https://svnweb.freebsd.org/changeset/base/310045 Log: Use casts to force an unsigned comparison in db_search_symbol(). On all of our platforms, db_expr_t is a signed integer while db_addr_t is an unsigned integer value. db_search_symbol used variables of type db_expr_t to hold the current offset of the requested address from the "best" symbol found so far. This value was initialized to '~0'. When a new symbol is found from a symbol table, the associated diff for the new symbol is compared against the existing value as 'if (newdiff < diff)' to determine if the new symbol had a smaller diff and was thus a closer match. On 64-bit MIPS, the '~0' was treated as a negative value (-1). A lookup that found a perfect match of an address against a symbol returned a diff of 0. However, in signed comparisons, 0 is not less than -1. As a result, DDB on 64-bit MIPS never resolved any addresses to symbols. Workaround this by using casts to force an unsigned comparison. Probably the diff returned from db_search_symbol() and X_db_search_symbol() should be changed to a db_addr_t instead of a db_expr_t as it is an unsigned value (and is an offset of an address, so should fit in the same size as an address). Sponsored by: DARPA / AFRL Modified: head/sys/ddb/db_sym.c Modified: head/sys/ddb/db_sym.c ============================================================================== --- head/sys/ddb/db_sym.c Tue Dec 13 23:34:07 2016 (r310044) +++ head/sys/ddb/db_sym.c Wed Dec 14 00:18:12 2016 (r310045) @@ -373,10 +373,10 @@ db_search_symbol(db_addr_t val, db_strat register int i; c_db_sym_t ret = C_DB_SYM_NULL, sym; - newdiff = diff = ~0; + newdiff = diff = val; for (i = 0; i < db_nsymtab; i++) { sym = X_db_search_symbol(&db_symtabs[i], val, strategy, &newdiff); - if (newdiff < diff) { + if ((uintmax_t)newdiff < (uintmax_t)diff) { db_last_symtab = &db_symtabs[i]; diff = newdiff; ret = sym;