aboutsummaryrefslogtreecommitdiff
path: root/sys/ddb/db_sym.c
Commit message (Collapse)AuthorAgeFilesLines
* db_search_symbol: prevent pollution from bogus symbolsEric van Gyzen2020-10-261-1/+14
| | | | | | | | | | | | | | | | | The kernel will never map the first page, so any symbols in that range cannot refer to addresses. Some third-party assembly files define internal constants which appear in their symbol table. Avoiding the lookup for those symbols avoids replacing small offsets with those symbols during disassembly. Reported by: Anton Rang <rang%acm.org> Reviewed by: Anton Rang <rang%acm.org>, markj MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D26895 Notes: svn path=/head/; revision=367059
* ddb: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-2/+0
| | | | Notes: svn path=/head/; revision=365227
* ddb: fix validation of cpu id in 'set db_cpu=x'Andriy Gapon2017-12-051-2/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=326567
* SPDX: Consider code from Carnegie-Mellon University.Pedro F. Giffuni2017-11-301-0/+2
| | | | | | | Interesting cases, most likely from CMU Mach sources. Notes: svn path=/head/; revision=326403
* Include opt files in the kernel with "" instead of <>.Warner Losh2017-07-101-1/+1
| | | | Notes: svn path=/head/; revision=320860
* Remove register keyword from sys/ and ANSIfy prototypesEd Maste2017-05-171-6/+5
| | | | | | | | | | | | | | | A long long time ago the register keyword told the compiler to store the corresponding variable in a CPU register, but it is not relevant for any compiler used in the FreeBSD world today. ANSIfy related prototypes while here. Reviewed by: cem, jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D10193 Notes: svn path=/head/; revision=318389
* Fix printing of negative offsets (typically from frame pointers) again.Bruce Evans2017-03-261-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I fixed this in 1997, but the fix was over-engineered and fragile and was broken in 2003 if not before. i386 parameters were copied to 8 other arches verbatim, mostly after they stopped working on i386, and mostly without the large comment saying how the values were chosen on i386. powerpc has a non-verbatim copy which just changes the uncritical parameter and seems to add a sign extension bug to it. Just treat negative offsets as offsets if they are no more negative than -db_offset_max (default -64K), and remove all the broken parameters. -64K is not very negative, but it is enough for frame and stack pointer offsets since kernel stacks are small. The over-engineering was mainly to go more negative than -64K for the negative offset format, without affecting printing for more than a single address. Addresses in the top 64K of a (full 32-bit or 64-bit) address space are now printed less well, but there aren't many interesting ones. For arches that have many interesting ones very near the top (e.g., 68k has interrupt vectors there), there would be no good limit for the negative offset format and -64K is a good as anything. Notes: svn path=/head/; revision=316001
* Use casts to force an unsigned comparison in db_search_symbol().John Baldwin2016-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=310045
* ddb: for pointers replace 0 with NULL.Pedro F. Giffuni2016-04-151-3/+3
| | | | | | | | | Mostly cosmetical, no functional change. Found with devel/coccinelle. Notes: svn path=/head/; revision=298073
* Fix KSTACK_PAGES issue when the default value was changed in KERNCONFZbigniew Bodek2015-07-161-0/+2
| | | | | | | | | | | | | | | | | | | | | If KSTACK_PAGES was changed to anything alse than the default, the value from param.h was taken instead in some places and the value from KENRCONF in some others. This resulted in inconsistency which caused corruption in SMP envorinment. Ensure all places where KSTACK_PAGES are used the opt_kstack_pages.h is included. The file opt_kstack_pages.h could not be included in param.h because was breaking the toolchain compilation. Reviewed by: kib Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3094 Notes: svn path=/head/; revision=285627
* Correct the function name in catch-all error handling case.Bjoern A. Zeeb2015-06-171-1/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=284508
* ddb: finish converting boolean values.Pedro F. Giffuni2015-05-211-15/+14
| | | | | | | | | | | | The replacement started at r283088 was necessarily incomplete without replacing boolean_t with bool. This also involved cleaning some type mismatches and ansifying old C function declarations. Pointed out by: bde Discussed with: bde, ian, jhb Notes: svn path=/head/; revision=283248
* ddb: stop boolean screaming.Pedro F. Giffuni2015-05-181-18/+18
| | | | | | | | | | TRUE --> true FALSE--> false Hinted by: NetBSD Notes: svn path=/head/; revision=283088
* ddb: ANSI-fy function declarations.Pedro F. Giffuni2014-10-121-45/+13
| | | | | | | MFC after: 5 days Notes: svn path=/head/; revision=273006
* Move two copies of the same definition to a common include file.Julian Elischer2010-04-141-6/+0
| | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=206639
* Merge the remainder of kern_vimage.c and vimage.h into vnet.c andRobert Watson2009-08-011-1/+1
| | | | | | | | | | | | | vnet.h, we now use jails (rather than vimages) as the abstraction for virtualization management, and what remained was specific to virtual network stacks. Minor cleanups are done in the process, and comments updated to reflect these changes. Reviewed by: bz Approved by: re (vimage blanket) Notes: svn path=/head/; revision=196019
* Build on Jeff Roberson's linker-set based dynamic per-CPU allocatorRobert Watson2009-07-141-0/+169
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (DPCPU), as suggested by Peter Wemm, and implement a new per-virtual network stack memory allocator. Modify vnet to use the allocator instead of monolithic global container structures (vinet, ...). This change solves many binary compatibility problems associated with VIMAGE, and restores ELF symbols for virtualized global variables. Each virtualized global variable exists as a "reference copy", and also once per virtual network stack. Virtualized global variables are tagged at compile-time, placing the in a special linker set, which is loaded into a contiguous region of kernel memory. Virtualized global variables in the base kernel are linked as normal, but those in modules are copied and relocated to a reserved portion of the kernel's vnet region with the help of a the kernel linker. Virtualized global variables exist in per-vnet memory set up when the network stack instance is created, and are initialized statically from the reference copy. Run-time access occurs via an accessor macro, which converts from the current vnet and requested symbol to a per-vnet address. When "options VIMAGE" is not compiled into the kernel, normal global ELF symbols will be used instead and indirection is avoided. This change restores static initialization for network stack global variables, restores support for non-global symbols and types, eliminates the need for many subsystem constructors, eliminates large per-subsystem structures that caused many binary compatibility issues both for monitoring applications (netstat) and kernel modules, removes the per-function INIT_VNET_*() macros throughout the stack, eliminates the need for vnet_symmap ksym(2) munging, and eliminates duplicate definitions of virtualized globals under VIMAGE_GLOBALS. Bump __FreeBSD_version and update UPDATING. Portions submitted by: bz Reviewed by: bz, zec Discussed with: gnn, jamie, jeff, jhb, julian, sam Suggested by: peter Approved by: re (kensmith) Notes: svn path=/head/; revision=195699
* Never zero-out db_last_symtab. Whan backtraces are doneKonstantin Belousov2006-06-161-1/+0
| | | | | | | | | | | | in parallel in several threads, one symbol lookup could clear db_last_symtab when another one going to use it as starting point for traversal. Approved by: pjd (mentor) MFC after: 1 month Notes: svn path=/head/; revision=159668
* Start each of the license/copyright comments with /*-Warner Losh2005-01-061-1/+1
| | | | Notes: svn path=/head/; revision=139747
* Add DDB_NUMSYM option which in addition to the symbolic representationPoul-Henning Kamp2004-02-241-0/+6
| | | | | | | | | | | | | | | | | | | | also prints the actual numerical value of the symbol in question. Users of addr2line(1) will be less proficient in hex arithmetic as a consequence. This amongst other things means that traceback lines change from: siointr1(c4016800,c073bda0,0,c06b699c,69f) at siointr1+0xc5 to siointr1(c4016800,c073bda0,0,c06b699c,69f) at 0xc062b0bd = siointr1+0xc5 I made this an option to avoid bikesheds. ~ ~ ~ Notes: svn path=/head/; revision=126204
* Use __FBSDID().David E. O'Brien2003-06-101-3/+4
| | | | Notes: svn path=/head/; revision=116176
* Remove __P.Alfred Perlstein2002-03-201-5/+4
| | | | Notes: svn path=/head/; revision=92756
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Quiet warnings on Alpha. (db_expr_t is a long on alpha, int on x86)Peter Wemm1999-07-011-2/+2
| | | | Notes: svn path=/head/; revision=48407
* Fixed -Wcast-qual warnings.Bruce Evans1999-02-121-3/+3
| | | | Notes: svn path=/head/; revision=43926
* Fix warnings in preparation for adding -Wall -Wcast-qual to theMatthew Dillon1999-01-271-17/+17
| | | | | | | | | | kernel compile. This commit includes significant work to proper handle const arguments for the DDB symbol routines. Notes: svn path=/head/; revision=43309
* Changes to support -Wall, -Wcast-qual. Had to make physical code changesMatthew Dillon1999-01-271-12/+15
| | | | | | | | in db_lookup() to avoid the *cp = 0 / *cp = ':' combo ( temporary nul-terminate-then-restore-original ) on a const char * string. Notes: svn path=/head/; revision=43289
* Examine all occurrences of sprintf(), strcat(), and str[n]cpy()Archie Cobbs1998-12-041-4/+2
| | | | | | | | | | | | | | | | | for possible buffer overflow problems. Replaced most sprintf()'s with snprintf(); for others cases, added terminating NUL bytes where appropriate, replaced constants like "16" with sizeof(), etc. These changes include several bug fixes, but most changes are for maintainability's sake. Any instance where it wasn't "immediately obvious" that a buffer overflow could not occur was made safer. Reviewed by: Bruce Evans <bde@zeta.org.au> Reviewed by: Matthew Dillon <dillon@apollo.backplane.com> Reviewed by: Mike Spengler <mks@networkcs.com> Notes: svn path=/head/; revision=41514
* Use not-so-new printf formats %r and/or %z instead of %n and/or %+x.Bruce Evans1998-07-081-4/+4
| | | | Notes: svn path=/head/; revision=37506
* Fixed bogus type of valuep in struct db_variable. It was `int *' andBruce Evans1998-07-081-3/+3
| | | | | | | | became `long *' for alpha, but should always have been `db_expr_t *'. Fixed variable types to match. Notes: svn path=/head/; revision=37504
* Fixed db_printf format errors.Bruce Evans1998-07-081-3/+3
| | | | Notes: svn path=/head/; revision=37497
* Supply the symbol table as an argument to X_db_symbol_values (required for elf).Doug Rabson1998-06-281-2/+2
| | | | Notes: svn path=/head/; revision=37218
* Add initial support for the FreeBSD/alpha kernel. This is very much aDoug Rabson1998-06-101-3/+3
| | | | | | | | | | | | | work in progress and has never booted a real machine. Initial development and testing was done using SimOS (see http://simos.stanford.edu for details). On the SimOS simulator, this port successfully reaches single-user mode and has been tested with loads as high as one copy of /bin/ls :-). Obtained from: partly from NetBSD/alpha Notes: svn path=/head/; revision=36849
* This commit fixes various 64bit portability problems required forDoug Rabson1998-06-071-3/+3
| | | | | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time. Notes: svn path=/head/; revision=36735
* Some staticized variables were still declared to be extern.Bruce Evans1997-06-301-4/+8
| | | | Notes: svn path=/head/; revision=27122
* Don't depend on gcc's feature of interpreting `int foo(c) char c; ...'Bruce Evans1997-06-301-2/+2
| | | | | | | | as `int foo(char c) ...' if there is a bogus prototype `int foo(char c);' in scope. Notes: svn path=/head/; revision=27121
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notPeter Wemm1997-02-221-1/+1
| | | | | | | ready for it yet. Notes: svn path=/head/; revision=22975
* Fixed printing of small offsets. E.g., -4(%ebp) is now printedBruce Evans1997-01-161-2/+8
| | | | | | | | | as -0x4(%ebp) instead of as _APTD+0xffc(%ebp), and if GUPROF is defined, 8(%ebp) is now printed as 0x8(%ebp) instead of as GMON_PROF_HIRES+0x4(%ebp). Notes: svn path=/head/; revision=21767
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-01-141-1/+1
| | | | | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise. Notes: svn path=/head/; revision=21673
* Get rid of two and a half printf in the kernel.Poul-Henning Kamp1996-01-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Add more features to the one remaining to handle the job: + signed quantity. # alternate format - left padding * read width as next arg. n numeric in (argument specified) default radix. Fix the DDB debugger to use these. Use vprintf in debug routine in pcvt. The warnings from gcc may become more wrong and intolerable because of this. Warning: I have not checked the entire source for unsupported or changed constructs, but generally belive that there are only a few. Suggested by: bde Notes: svn path=/head/; revision=13446
* Reduced and cleaned up #includes.Bruce Evans1995-12-101-3/+2
| | | | Notes: svn path=/head/; revision=12734
* Staticize and cleanup.Poul-Henning Kamp1995-12-101-2/+2
| | | | Notes: svn path=/head/; revision=12720
* Untangled the vm.h include file spaghetti.David Greenman1995-12-071-1/+2
| | | | Notes: svn path=/head/; revision=12662
* Staticized and '#ifdef notused' stuff we don't use.Poul-Henning Kamp1995-11-291-9/+11
| | | | Notes: svn path=/head/; revision=12515
* Completed function declarations and/or added prototypes and/or #includesBruce Evans1995-11-241-10/+4
| | | | | | | | | | | | | to get the prototypes. Changed some `int's to `boolean_t's. boolean_t's are ints so they are hard to distinguish from ints. Converted function headers to old-style. ddb is written in K&R1 C except where we broke it. Notes: svn path=/head/; revision=12473
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-8/+8
| | | | Notes: svn path=/head/; revision=8876
* Print the address associated with an examine. Changed db_maxoff toDavid Greenman1995-05-221-2/+2
| | | | | | | | something more reasonable (64k). Suggested by Gordon Ross about a year ago. Notes: svn path=/head/; revision=8698
* Makes gcc silent in sys/ddb.Poul-Henning Kamp1994-09-271-9/+6
| | | | Notes: svn path=/head/; revision=3140
* 1) cleaned up after Garrett - fixed more redundant declarations, changedDavid Greenman1994-08-201-5/+5
| | | | | | | | | | | use of timeout_t -> timeout_func_t in aha1542 and aha1742 drivers. 2) fix a bug in the portalfs that was uncovered by better prototyping - specifically, the time must be converted from timeval to timespec before storing in va_atime. 3) fixed/added some miscellaneous prototypes Notes: svn path=/head/; revision=2142
* Change all #includes to follow the current Berkeley style. Some of theseGarrett Wollman1994-08-131-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | ``changes'' are actually not changes at all, but CVS sometimes has trouble telling the difference. This also includes support for second-directory compiles. This is not quite complete yet, as `config' doesn't yet do the right thing. You can still make it work trivially, however, by doing the following: rm /sys/compile mkdir /usr/obj/sys/compile ln -s M-. /sys/compile cd /sys/i386/conf config MYKERNEL cd ../../compile/MYKERNEL ln -s /sys @ rm machine ln -s @/i386/include machine make depend make Notes: svn path=/head/; revision=2056