Commit Graph

52 Commits

Author SHA1 Message Date
Andriy Gapon
6e1c5d187c ddb: fix validation of cpu id in 'set db_cpu=x'
MFC after:	1 week
2017-12-05 14:22:08 +00:00
Pedro F. Giffuni
796df753f4 SPDX: Consider code from Carnegie-Mellon University.
Interesting cases, most likely from CMU Mach sources.
2017-11-30 15:48:35 +00:00
Warner Losh
4e38d89520 Include opt files in the kernel with "" instead of <>. 2017-07-10 05:08:01 +00:00
Ed Maste
3e85b721d6 Remove register keyword from sys/ and ANSIfy prototypes
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
2017-05-17 00:34:34 +00:00
Bruce Evans
f434f3515b Fix printing of negative offsets (typically from frame pointers) again.
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.
2017-03-26 18:46:35 +00:00
John Baldwin
ecb65f66c6 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
2016-12-14 00:18:12 +00:00
Pedro F. Giffuni
9f915a92c7 ddb: for pointers replace 0 with NULL.
Mostly cosmetical, no functional change.

Found with devel/coccinelle.
2016-04-15 17:27:20 +00:00
Zbigniew Bodek
721555e7ee Fix KSTACK_PAGES issue when the default value was changed in KERNCONF
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
2015-07-16 10:46:52 +00:00
Bjoern A. Zeeb
8fe344fa48 Correct the function name in catch-all error handling case.
MFC after:	1 week
2015-06-17 10:20:59 +00:00
Pedro F. Giffuni
cd508278c1 ddb: finish converting boolean values.
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
2015-05-21 15:16:18 +00:00
Pedro F. Giffuni
2b490bc747 ddb: stop boolean screaming.
TRUE --> true
FALSE--> false

Hinted by:	NetBSD
2015-05-18 22:27:46 +00:00
Pedro F. Giffuni
a41dd0319c ddb: ANSI-fy function declarations.
MFC after:	5 days
2014-10-12 18:01:52 +00:00
Julian Elischer
7a90b21212 Move two copies of the same definition to a common include file.
MFC after: 3 weeks
2010-04-14 23:06:07 +00:00
Robert Watson
530c006014 Merge the remainder of kern_vimage.c and vimage.h into vnet.c and
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)
2009-08-01 19:26:27 +00:00
Robert Watson
eddfbb763d Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(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)
2009-07-14 22:48:30 +00:00
Konstantin Belousov
d48b6d9ad6 Never zero-out db_last_symtab. Whan backtraces are done
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
2006-06-16 16:17:52 +00:00
Warner Losh
dd3cb56845 Start each of the license/copyright comments with /*- 2005-01-06 01:34:41 +00:00
Poul-Henning Kamp
9aece96fc0 Add DDB_NUMSYM option which in addition to the symbolic representation
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.
~
~
~
2004-02-24 22:51:42 +00:00
David E. O'Brien
753960f7c4 Use __FBSDID(). 2003-06-10 22:09:23 +00:00
Alfred Perlstein
14e10f9952 Remove __P. 2002-03-20 05:14:42 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Peter Wemm
1c6989fa7e Quiet warnings on Alpha. (db_expr_t is a long on alpha, int on x86) 1999-07-01 19:42:56 +00:00
Bruce Evans
1e66367c66 Fixed -Wcast-qual warnings. 1999-02-12 12:44:19 +00:00
Matthew Dillon
fe08c21a53 Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile.

    This commit includes significant work to proper handle const arguments
    for the DDB symbol routines.
1999-01-27 23:45:44 +00:00
Matthew Dillon
a1c1e16ada Changes to support -Wall, -Wcast-qual. Had to make physical code changes
in db_lookup() to avoid the *cp = 0 / *cp = ':' combo ( temporary
    nul-terminate-then-restore-original ) on a const char * string.
1999-01-27 19:00:49 +00:00
Archie Cobbs
2127f26023 Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
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>
1998-12-04 22:54:57 +00:00
Bruce Evans
596dfc04ed Use not-so-new printf formats %r and/or %z instead of %n and/or %+x. 1998-07-08 10:53:58 +00:00
Bruce Evans
3da6ef3c3a Fixed bogus type of valuep in struct db_variable. It was `int *' and
became `long *' for alpha, but should always have been `db_expr_t *'.
Fixed variable types to match.
1998-07-08 09:11:43 +00:00
Bruce Evans
90163a9b33 Fixed db_printf format errors. 1998-07-08 06:43:57 +00:00
Doug Rabson
6edf3d9144 Supply the symbol table as an argument to X_db_symbol_values (required for elf). 1998-06-28 00:55:02 +00:00
Doug Rabson
897cd717a5 Add initial support for the FreeBSD/alpha kernel. This is very much a
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
1998-06-10 10:57:29 +00:00
Doug Rabson
ecbb00a262 This commit fixes various 64bit portability problems required for
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.
1998-06-07 17:13:14 +00:00
Bruce Evans
94e24bf0f5 Some staticized variables were still declared to be extern. 1997-06-30 23:54:50 +00:00
Bruce Evans
b2b392c442 Don't depend on gcc's feature of interpreting `int foo(c) char c; ...'
as `int foo(char c) ...' if there is a bogus prototype `int foo(char c);'
in scope.
1997-06-30 23:49:17 +00:00
Peter Wemm
6875d25465 Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.
1997-02-22 09:48:43 +00:00
Bruce Evans
7d350e7256 Fixed printing of small offsets. E.g., -4(%ebp) is now printed
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).
1997-01-16 11:27:11 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
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.
1997-01-14 07:20:47 +00:00
Poul-Henning Kamp
791d77e0dd Get rid of two and a half printf in the kernel.
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
1996-01-15 22:41:03 +00:00
Bruce Evans
5ccbc3cc5a Reduced and cleaned up #includes. 1995-12-10 19:08:32 +00:00
Poul-Henning Kamp
25eb640d90 Staticize and cleanup. 1995-12-10 13:32:43 +00:00
David Greenman
efeaf95a41 Untangled the vm.h include file spaghetti. 1995-12-07 12:48:31 +00:00
Poul-Henning Kamp
f73a856d23 Staticized and '#ifdef notused' stuff we don't use. 1995-11-29 10:25:50 +00:00
Bruce Evans
058284fceb Completed function declarations and/or added prototypes and/or #includes
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.
1995-11-24 14:13:42 +00:00
Rodney W. Grimes
9b2e535452 Remove trailing whitespace. 1995-05-30 08:16:23 +00:00
David Greenman
751b0b8e10 Print the address associated with an examine. Changed db_maxoff to
something more reasonable (64k). Suggested by Gordon Ross about a
year ago.
1995-05-22 13:07:12 +00:00
Poul-Henning Kamp
169cd910b7 Makes gcc silent in sys/ddb. 1994-09-27 03:34:58 +00:00
David Greenman
7b42c960f8 1) cleaned up after Garrett - fixed more redundant declarations, changed
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
1994-08-20 03:49:02 +00:00
Garrett Wollman
f540b1065a Change all #includes to follow the current Berkeley style. Some of these
``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
1994-08-13 03:50:34 +00:00
David Greenman
f7d757443b Patches from John Brezak (necessary for the syscall->trapframe conversion
as well as add additional functionality):

Print symbolic args and line no's in stack traces.
1994-01-03 07:54:10 +00:00
Garrett Wollman
381fe1aaf4 Make the LINT kernel compile with -W -Wreturn-type -Wcomment -Werror, and
add same (sans -Werror) to Makefile for future compilations.
1993-11-25 01:38:01 +00:00