aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/amd64/db_trace.c
Commit message (Collapse)AuthorAgeFilesLines
* amd64: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-5/+0
| | | | Notes: svn path=/head/; revision=365067
* teach db_nextframe/x86 about [X]xen_intr_upcall interrupt handlerAndriy Gapon2019-11-121-0/+1
| | | | | | | | | Discussed with: kib, royger MFC after: 3 weeks Sponsored by: Panzura Notes: svn path=/head/; revision=354638
* db_nextframe/amd64: remove TRAP_INTERRUPT frame typeAndriy Gapon2019-11-111-9/+0
| | | | | | | | | | | | | | Besides the confusing name, this type is effectively unused. In all cases where it could be set, the INTERRUPT type is set by the earlier code. The conditions for TRAP_INTERRUPT are a subset of the conditions for INTERRUPT. Reviewed by: kib, markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D22305 Notes: svn path=/head/; revision=354619
* Move most of the contents of opt_compat.h to opt_global.h.Brooks Davis2018-04-061-2/+0
| | | | | | | | | | | | | | | | | | | | | opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941 Notes: svn path=/head/; revision=332122
* db_nextframe/amd64: catch up with r328083 to recognize fast_syscall_commonAndriy Gapon2018-03-031-1/+3
| | | | | | | | | | | | | | | | Since that change the system call stack traces look like this: ... sys___sysctl() at sys___sysctl+0x5f/frame 0xfffffe0028e13ac0 amd64_syscall() at amd64_syscall+0x79b/frame 0xfffffe0028e13bf0 fast_syscall_common() at fast_syscall_common+0x101/frame 0xfffffe0028e13bf0 So, db_nextframe() stopped recognizing the system call frame. This commit should fix that. Reviewed by: kib MFC after: 4 days Notes: svn path=/head/; revision=330338
* Ensure 'name' is not NULL before passing to strcmp().John Baldwin2018-01-301-1/+2
| | | | | | | | | | | This avoids a nested page fault when obtaining a stack trace in DDB if the address from the first frame does not resolve to a known symbol. MFC after: 1 week Sponsored by: Chelsio Communications Notes: svn path=/head/; revision=328610
* Use a dedicated per-CPU stack for machine check exceptions.John Baldwin2018-01-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Similar to NMIs, machine check exceptions can fire at any time and are not masked by IF. This means that machine checks can fire when the kstack is too deep to hold a trap frame, or at critical sections in trap handlers when a user %gs is used with a kernel %cs. Use the same strategy used for NMIs of using a dedicated per-CPU stack configured in IST 3. Store the CPU's pcpu pointer at the stop of the stack so that the machine check handler can reliably find the proper value for %gs (also borrowed from NMIs). This should also fix a similar issue with PTI with a MC# occurring while the CPU is executing on the trampoline stack. While here, bypass trap() entirely and just call mca_intr(). This avoids a bogus call to kdb_reenter() (there's no reason to try to reenter kdb if a MC# is raised). Reviewed by: kib Tested by: avg (on AMD without PTI) Differential Revision: https://reviews.freebsd.org/D13962 Notes: svn path=/head/; revision=328157
* Don't access the reserved registers %dr4 and %dr5 on i386.Bruce Evans2017-03-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On the original i386, %dr[4-5] were unimplemented but not very clearly reserved, so debuggers read them to print them. i386 was still doing this. On the original athlon64, %dr[4-5] are documented as reserved but are aliased to %dr[6-7] unless CR4_DE is set, when accessing them traps. On 2 of my systems, accessing %dr[4-5] trapped sometimes. On my Haswell system, the apparent randomness was because the boot CPU starts with CR4_DE set while all other CPUs start with CR4_DE clear. FreeBSD doesn't support the data breakpoints enabled by CR4_DE and it never changes this flag, so the flag remains different across CPUs and the behaviour seemed inconsistent except while booting when the CPU doesn't change. The invalid accesses broke: - read access for printing the registers in ddb "show watches" on CPUs with CR4_DE set - read accesses in fill_dbregs() on CPUs with CR4_DE set. This didn't implement panic(3) since the user case always skipped %dr[4-5]. - write accesses in set_dbregs(). This also didn't affect userland. When it didn't trap, the aliasing made it fragile. Don't print the dummy (zero) values of %dr[4-5] in "show watches" for i386 or amd64. Fix style bugs near this printing. amd64 also has space in the dbregs struct for the reserved %dr[8-15] and already didn't print the dummy values for these, and never accessed any of the 10 reserved debug registers. Remove cpufuncs for making the invalid accesses. Even amd64 had these. Notes: svn path=/head/; revision=315454
* Revert crap accidentally committedBaptiste Daroussin2017-01-281-15/+0
| | | | Notes: svn path=/head/; revision=312927
* Revert r312923 a better approach will be taken laterBaptiste Daroussin2017-01-281-0/+15
| | | | Notes: svn path=/head/; revision=312926
* Various changes to the registers displayed in DDB for x86.John Baldwin2015-07-221-46/+23
| | | | | | | | | | | | | | | | | | | - Fix segment registers to only display the low 16 bits. - Remove unused handlers and entries for the debug registers. - Display xcr0 (if valid) in 'show sysregs'. - Add '0x' prefix to MSR values to match other values in 'show sysregs'. - MFamd64: Display various MSRs in 'show sysregs'. - Add a 'show dbregs' to display the value of debug registers. - Dynamically size the column width for register values to properly align columns on 64-bit platforms. - Display %gs for i386 in 'show registers'. Differential Revision: https://reviews.freebsd.org/D2784 Reviewed by: kib, markj MFC after: 2 weeks Notes: svn path=/head/; revision=285783
* Let the unwinder handle faults during function prologues or epilogues.Mark Johnston2015-07-211-45/+10
| | | | | | | | | | | | | | | | | | | | | The i386 and amd64 DDB stack unwinders contain code to detect and handle the case where the first frame is not completely set up or torn down. This code was accidentally unused however, since db_backtrace() was never called with a non-NULL trap frame. This change fixes that. Also remove get_rsp() from the amd64 code. It appears to have come from i386, which needs to take into account whether the exception triggered a CPL switch, since SS:ESP is only pushed onto the stack if so. On amd64, SS:RSP is pushed regardless, so get_rsp() was doing the wrong thing for kernel-mode exceptions. As a result, we can also remove custom print functions for these registers. Reviewed by: jhb Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D2881 Notes: svn path=/head/; revision=285776
* Improve stack unwinding on i386 and amd64 after an IP fault.Mark Johnston2015-07-211-7/+19
| | | | | | | | | | | | | | | | If we can't find a symbol corresponding to the faulting instruction, assume that the previously-executed function is a call and attempt to find the calling function using the return address on the stack. Otherwise we end up associating the last stack frame with the current call, which is incorrect and causes the unwinder to skip printing of the calling function, resulting in a confusing backtrace. Reviewed by: jhb Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D2859 Notes: svn path=/head/; revision=285775
* Remove some dead code from DDB's amd64 stack unwinder.Mark Johnston2015-07-211-74/+8
| | | | | | | | | | | | | | | The amd64 port copied some code from i386 to fetch function arguments and display them in backtraces. However, it was commented out and can't easily be implemented since the function arguments are passed in registers rather than on the stack in amd64. Remove it in preparation for some bug fixes in this area. Reviewed by: jhb Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D2857 Notes: svn path=/head/; revision=285773
* Fix the hardware watchpoints on SMP amd64. Load the updated %drKonstantin Belousov2013-05-211-22/+57
| | | | | | | | | | | | | | registers also on other CPUs, besides the CPU which happens to execute the ddb. The debugging registers are stored in the pcpu area, together with the command which is executed by the IPI stop handler upon resume. Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=250851
* Print the frame addresses for the backtraces on i386 and amd64. ItKonstantin Belousov2012-12-031-6/+11
| | | | | | | | | | | allows both to inspect the frame sizes and to manually peek into the frames from ddb, if needed. Reviewed by: dim MFC after: 2 weeks Notes: svn path=/head/; revision=243836
* Provide groundwork for 32-bit binary compatibility on non-x86 platforms,Nathan Whitehorn2010-03-111-1/+1
| | | | | | | | | | | | for upcoming 64-bit PowerPC and MIPS support. This renames the COMPAT_IA32 option to COMPAT_FREEBSD32, removes some IA32-specific code from MI parts of the kernel and enhances the freebsd32 compatibility code to support big-endian platforms. Reviewed by: kib, jhb Notes: svn path=/head/; revision=205014
* Save and restore segment registers on amd64 when entering and leavingKonstantin Belousov2009-04-011-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the kernel on amd64. Fill and read segment registers for mcontext and signals. Handle traps caused by restoration of the invalidated selectors. Implement user-mode creation and manipulation of the process-specific LDT descriptors for amd64, see sysarch(2). Implement support for TSS i/o port access permission bitmap for amd64. Context-switch LDT and TSS. Do not save and restore segment registers on the context switch, that is handled by kernel enter/leave trampolines now. Remove segment restore code from the signal trampolines for freebsd/amd64, freebsd/ia32 and linux/i386 for the same reason. Implement amd64-specific compat shims for sysarch. Linuxolator (temporary ?) switched to use gsbase for thread_area pointer. TODO: Currently, gdb is not adapted to show segment registers from struct reg. Also, no machine-depended ptrace command is added to set segment registers for debugged process. In collaboration with: pho Discussed with: peter Reviewed by: jhb Linuxolator tested by: dchagin Notes: svn path=/head/; revision=190620
* Initial suspend/resume support for amd64.Jung-uk Kim2009-03-171-0/+2
| | | | | | | | | This code is heavily inspired by Takanori Watanabe's experimental SMP patch for i386 and large portion was shamelessly cut and pasted from Peter Wemm's AP boot code. Notes: svn path=/head/; revision=189903
* Improve db_backtrace() for compat ia32 on amd64. 32bit image entersKonstantin Belousov2008-12-051-0/+6
| | | | | | | | | | the kernel via Xint0x80_syscall(). Submitted by: dchagin MFC after: 1 week Notes: svn path=/head/; revision=185634
* Break out stack(9) from ddb(4):Robert Watson2007-12-021-38/+1
| | | | | | | | | | | | | | | | | | | | | | | - Introduce per-architecture stack_machdep.c to hold stack_save(9). - Introduce per-architecture machine/stack.h to capture any common definitions required between db_trace.c and stack_machdep.c. - Add new kernel option "options STACK"; we will build in stack(9) if it is defined, or also if "options DDB" is defined to provide compatibility with existing users of stack(9). Add new stack_save_td(9) function, which allows the capture of a stacktrace of another thread rather than the current thread, which the existing stack_save(9) was limited to. It requires that the thread be neither swapped out nor running, which is the responsibility of the consumer to enforce. Update stack(9) man page. Build tested: amd64, arm, i386, ia64, powerpc, sparc64, sun4v Runtime tested: amd64 (rwatson), arm (cognet), i386 (rwatson) Notes: svn path=/head/; revision=174195
* Add support for cross double fault frames in stack traces:John Baldwin2007-11-151-1/+2
| | | | | | | | | | | - Populate the register values for the trapframe put on the stack by the double fault handler. - Teach DDB's trace routine to treat a double fault like other trap frames. MFC after: 3 days Notes: svn path=/head/; revision=173659
* Add support for 8 byte hardware watches in long mode. Kernel hardwareJohn Baldwin2006-11-171-4/+14
| | | | | | | | watches support 8 byte watches. For userland, we disallow 8 byte watches for 32-bit tasks. Notes: svn path=/head/; revision=164365
* - Add macro constants for the various fields in %dr7 and use them in placeJohn Baldwin2006-11-171-30/+33
| | | | | | | | | | of various scattered magic values. - Pretty print the address of hardware watchpoints in 'show watch' rather than just displaying hex. - Expand address field width on amd64 for 64-bit pointers. Notes: svn path=/head/; revision=164362
* A few more style fixes.John Baldwin2006-11-171-4/+3
| | | | Notes: svn path=/head/; revision=164357
* Various whitespace and style fixes.John Baldwin2006-11-151-36/+35
| | | | Notes: svn path=/head/; revision=164303
* Don't show debug registers in "show registers". Special registers shouldBruce Evans2006-10-201-1/+2
| | | | | | | | | | be displayed specially, and debug registers are among of the least interesting special registers (far behind %cr3). The debug registers are still accessible as variables and displayed in another bogus place ("show watches"). Notes: svn path=/head/; revision=163534
* Simplify the pager support in DDB. Allowing different db commands toJohn Baldwin2006-07-121-4/+2
| | | | | | | | | | | | | | | | | | | install custom pager functions didn't actually happen in practice (they all just used the simple pager and passed in a local quit pointer). So, just hardcode the simple pager as the only pager and make it set a global db_pager_quit flag that db commands can check when the user hits 'q' (or a suitable variant) at the pager prompt. Also, now that it's easy to do so, enable paging by default for all ddb commands. Any command that wishes to honor the quit flag can do so by checking db_pager_quit. Note that the pager can also be effectively disabled by setting $lines to 0. Other fixes: - 'show idt' on i386 and pc98 now actually checks the quit flag and terminates early. - 'show intr' now actually checks the quit flag and terminates early. Notes: svn path=/head/; revision=160312
* MFi386: add a TRAP_INTERRUPT casePeter Wemm2006-03-131-0/+8
| | | | Notes: svn path=/head/; revision=156695
* Fix watch address truncation. The address was truncated when it was passed toPawel Jakub Dawidek2005-12-271-3/+3
| | | | | | | | | | amd64_set_watch() as 'unsigned int' and 'unsigned int' is 32bit long on amd64. Even with that fix hardware watchpoint don't work for me on amd64, ie. when I set the watchpoint and write a byte there, nothing happens. Notes: svn path=/head/; revision=153766
* - Improve the INKERNEL macro such that it can no longer give false positives.Jeff Roberson2005-12-231-1/+5
| | | | | | | | | This fixes the stack(9) functionality. Submitted by: Antoine Brodin <antoine.brodin@laposte.net> Notes: svn path=/head/; revision=153694
* MFi386:John Baldwin2005-12-081-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | - Move PUSH_FRAME and POP_FRAME to asmacros.h and use PUSH_FRAME in atpic entry points. - Move PCPU_* asm macros out of the middle of the asm profiling macros. - Pass IRQ vector argument as an int rather than void * to reduce diffs with i386. - EOI the lapic in C for the lapic timer handler. - GC unused Xcpuast function. - Split IPI_STOP handling code of ipi_nmi_handler() out into a cpustop_handler() function and call it from Xcpustop rather than duplicating all the logic in assembly. - Fixup the list of symbols with interrupt frames in ddb traces. Xatpic_fastintr* have never existed on amd64, and the lapic timer handler and various IPI handlers were missing. - Use trapframe instead of intrframe for interrupt entry points (on amd64 the interrupt vector was already a separate argument, so the two frames were already identical) and GC intrframe. Submitted by: peter (3) Notes: svn path=/head/; revision=153241
* Move the prototypes of db_md_set_watchpoint(), db_md_clr_watchpoint()Marcel Moolenaar2005-09-101-3/+0
| | | | | | | and db_md_list_watchpoints() to ddb/ddb.h. Notes: svn path=/head/; revision=149925
* - Special-case NMI handling on the AMD64.Joseph Koshy2005-08-271-1/+2
| | | | | | | | | | | | | | | | | | | | | On entry or exit from the kernel the 'alltraps' and 'doreti' code used taken by normal traps disables interrupts to protect the critical sections where it is setting up %gs. This protection is insufficient in the presence of NMIs since NMIs can be taken even when the processor has disabled normal interrupts. Thus the NMI handler needs to actually read MSR_GBASE on entry to the kernel to determine whether a swap of %gs using 'swapgs' is needed. However, reads of MSRs are expensive and integrating this check into the 'alltraps'/'doreti' path would penalize normal interrupts. - Teach DDB about the 'nmi_calltrap' symbol. Reviewed by: bde, peter (older versions of this change) Notes: svn path=/head/; revision=149526
* - Add support for saving stack traces and displaying them via printf(9)Jeff Roberson2005-08-031-0/+23
| | | | | | | | | | and KTR. Contributed by: Antoine Brodin <antoine.brodin@laposte.net> Concept code from: Neal Fachan <neal@isilon.com> Notes: svn path=/head/; revision=148667
* - Improve the definition of INKERNEL() to include the DMAP area and theJeff Roberson2005-08-031-1/+2
| | | | | | | | | proper start of the kernel area. Discussed with: peter Notes: svn path=/head/; revision=148664
* MFi386: use %rip - 1 for the symbol search address (for noreturn funcs)Peter Wemm2005-01-211-2/+8
| | | | Notes: svn path=/head/; revision=140552
* Begin all license/copyright comments with /*-Warner Losh2005-01-051-1/+1
| | | | Notes: svn path=/head/; revision=139731
* - Change the ddb paging "support" to use a variable (db_lines_per_page) toJohn Baldwin2004-11-011-1/+1
| | | | | | | | | | | | | | | | | | | | control the number of lines per page rather than a constant. The variable can be examined and changed in ddb as '$lines'. Setting the variable to 0 will effectively turn off paging. - Change db_putchar() to force out pending whitespace before outputting newlines and carriage returns so that one can rub out content on the current line via '\r \r' type strings. - Change the simple pager to rub out the --More-- prompt explicitly when the routine exits. - Add some aliases to the simple pager to make it more compatible with more(1): 'e' and 'j' do a single line. 'd' does half a page, and 'f' does a full page. MFC after: 1 month Inspired by: kris Notes: svn path=/head/; revision=137117
* - Add support for "paging" in stack trace output. That is, when you doJohn Baldwin2004-09-201-2/+4
| | | | | | | | | | | | | | | | a stack trace from ddb, the output will pause with a '--More--' prompt every 18 lines. If you hit Enter, it will print another line and prompt again. If you hit space it will output another page and then prompt. If you hit 'q' or 'x' it will abort the rest of the stack trace. - Fix the sparc64 userland stack trace to honor the total count of lines to print. This is useful if your trace happens to walk back onto 0xdeadc0de and gets stuck in an endless loop. MFC after: 1 month Tested on: i386, alpha, sparc64 Notes: svn path=/head/; revision=135529
* Unify db_stack_trace_cmd(). All it did was look up the thread givenMarcel Moolenaar2004-07-211-14/+0
| | | | | | | | | | | | | | | | | | the thread ID and call db_trace_thread(). Since arm has all the logic in db_stack_trace_cmd(), rename the new DB_COMMAND function to db_stack_trace to avoid conflicts on arm. While here, have db_stack_trace parse its own arguments so that we can use a more natural radix for IDs. If the ID is not a thread ID, or more precisely when no thread exists with the ID, try if there's a process with that ID and return the first thread in it. This makes it easier to print stack traces from the ps output. requested by: rwatson@ tested on: amd64, i386, ia64 Notes: svn path=/head/; revision=132482
* Mega update for the KDB framework: turn DDB into a KDB backend.Marcel Moolenaar2004-07-101-225/+191
| | | | | | | | | | | | | | | | | | | Most of the changes are a direct result of adding thread awareness. Typically, DDB_REGS is gone. All registers are taken from the trapframe and backtraces use the PCB based contexts. DDB_REGS was defined to be a trapframe on all platforms anyway. Thread awareness introduces the following new commands: thread X switch to thread X (where X is the TID), show threads list all threads. The backtrace code has been made more flexible so that one can create backtraces for any thread by giving the thread ID as an argument to trace. With this change, ia64 has support for breakpoints. Notes: svn path=/head/; revision=131952
* Un-stub the hardware debug register stuff.Peter Wemm2004-01-281-33/+3
| | | | Notes: svn path=/head/; revision=125179
* Initial landing of SMP support for FreeBSD/amd64.Peter Wemm2003-11-171-2/+3
| | | | | | | | | | | | | | | | | | | - This is heavily derived from John Baldwin's apic/pci cleanup on i386. - I have completely rewritten or drastically cleaned up some other parts. (in particular, bootstrap) - This is still a WIP. It seems that there are some highly bogus bioses on nVidia nForce3-150 boards. I can't stress how broken these boards are. I have a workaround in mind, but right now the Asus SK8N is broken. The Gigabyte K8NPro (nVidia based) is also mind-numbingly hosed. - Most of my testing has been with SCHED_ULE. SCHED_4BSD works. - the apic and acpi components are 'standard'. - If you have an nVidia nForce3-150 board, you are stuck with 'device atpic' in addition, because they somehow managed to forget to connect the 8254 timer to the apic, even though its in the same silicon! ARGH! This directly violates the ACPI spec. Notes: svn path=/head/; revision=122849
* Use __FBSDID().David E. O'Brien2003-07-251-2/+3
| | | | | | | Brought to you by: a boring talk at Ottawa Linux Symposium Notes: svn path=/head/; revision=118031
* MFi386: rev 1.56: remove break after returnPeter Wemm2003-05-311-2/+2
| | | | Notes: svn path=/head/; revision=115577
* Initial port to amd64 after repocopy from i386. Note that thePeter Wemm2003-05-301-99/+137
| | | | | | | | | | | | disassembler has not been updated yet, and will do some very strange things. It does tracebacks (without function arguments due to regparm calling conventions) if -fno-omit-frame-pointer is used (to come later). This achieves basic functionality. Approved by: re (amd64/* blanket) Notes: svn path=/head/; revision=115403
* Add code to ddb to allow backtracing an arbitrary thread.Julian Elischer2002-12-281-2/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | (show thread {address}) Remove the IDLE kse state and replace it with a change in the way threads sahre KSEs. Every KSE now has a thread, which is considered its "owner" however a KSE may also be lent to other threads in the same group to allow completion of in-kernel work. n this case the owner remains the same and the KSE will revert to the owner when the other work has been completed. All creations of upcalls etc. is now done from kse_reassign() which in turn is called from mi_switch or thread_exit(). This means that special code can be removed from msleep() and cv_wait(). kse_release() does not leave a KSE with no thread any more but converts the existing thread into teh KSE's owner, and sets it up for doing an upcall. It is just inhibitted from being scheduled until there is some reason to do an upcall. Remove all trace of the kse_idle queue since it is no-longer needed. "Idle" KSEs are now on the loanable queue. Notes: svn path=/head/; revision=108338
* Change the definition of the debugging registers to be an array, soPoul-Henning Kamp2002-10-201-10/+10
| | | | | | | | | | that we can index into it, rather than do pointer gymnastics on a structure containing 8 elements. Verified by: MD5 hash on the produced .o files. Notes: svn path=/head/; revision=105554
* fork_trampoline() marks a trap frame.John Baldwin2002-09-201-1/+2
| | | | | | | Submitted by: bde Notes: svn path=/head/; revision=103682