aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/gcore/elfcore.c
Commit message (Collapse)AuthorAgeFilesLines
* gcore: Avoid using vm_map_entry_t.Mark Johnston2019-12-071-20/+27
| | | | | | | | | | Use an internally defined structure instead, to avoid relying on kernel structure details. No functional change intended. MFC after: 1 week Notes: svn path=/head/; revision=355506
* gcore: Don't add VSX notes on powerpcspeJustin Hibbits2019-11-161-0/+2
| | | | | | | | powerpcspe does not support VSX at all, but gets the 'VMX' notes for free, providing the SPE registers. Notes: svn path=/head/; revision=354778
* Included VSX registers in powerpc core dumpsJustin Hibbits2018-06-021-0/+26
| | | | | | | | | | Summary: Included VSX registers in powerpc core dumps (both kernel and gcore) Submitted by: Luis Pires Differential Revision: https://reviews.freebsd.org/D15512 Notes: svn path=/head/; revision=334538
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326276
* Add a NT_ARM_VFP ELF core note to hold VFP registers for each thread.John Baldwin2017-09-141-0/+31
| | | | | | | | | | | | | The core note matches the format and layout of NT_ARM_VFP on Linux. Debuggers use the AT_HWCAP flags to determine how many VFP registers are actually used and their format. Reviewed by: mmel (earlier version w/o gcore) MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D12293 Notes: svn path=/head/; revision=323584
* Store a 32-bit PT_LWPINFO struct for 32-bit process core dumps.John Baldwin2017-06-291-4/+12
| | | | | | | | | | | | Process core notes for a 32-bit process running on a 64-bit host need to use 32-bit structures so that the note layout matches the layout of notes of a core dump of a 32-bit process under a 32-bit kernel. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D11407 Notes: svn path=/head/; revision=320481
* Add support for capturing 'struct ptrace_lwpinfo' for signalsTycho Nightingale2017-03-301-0/+21
| | | | | | | | | | | | resulting in a process dumping core in the corefile. Also extend procstat to view select members of 'struct ptrace_lwpinfo' from the contents of the note. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316286
* Trim trailing whitespace (mostly introduced in r313407).John Baldwin2017-02-081-1/+1
| | | | | | | Sponsored by: DARPA / AFRL Notes: svn path=/head/; revision=313449
* Copy the e_machine and e_flags fields from the binary into an ELF core dump.John Baldwin2017-02-071-8/+15
| | | | | | | | | | | | | | | | In the kernel, cache the machine and flags fields from ELF header to use in the ELF header of a core dump. For gcore, the copy these fields over from the ELF header in the binary. This matters for platforms which encode ABI information in the flags field (such as o32 vs n32 on MIPS). Reviewed by: kib Sponsored by: DARPA / AFRL Differential Revision: https://reviews.freebsd.org/D9392 Notes: svn path=/head/; revision=313407
* Mirror r303120 to gcoreConrad Meyer2016-07-211-6/+6
| | | | | | | Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=303122
* Add extended segment support to gcoreConrad Meyer2016-07-201-3/+31
| | | | | | | | | | | | | | A follow-up to r303099, D7255. Basically, apply the exact same change, with the exact same rationale, to gcore. gcore's elfcore.c is largely a clone of the kernel imgact_elf coredump facility. Reviewed by: emaste (earlier version, not substantially different) Requested by: jhb Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D7265 Notes: svn path=/head/; revision=303114
* Include process IDs in core dumps.John Baldwin2016-07-181-0/+1
| | | | | | | | | | | | | | | | When threads were added to the kernel, the pr_pid member of the NT_PRSTATUS note was repurposed to store LWP IDs instead of process IDs. However, the process ID was no longer recorded in core dumps. This change adds a pr_pid field to prpsinfo (NT_PRSINFO). Rather than bumping the prpsinfo version number, note parsers can use the note's payload size to determine if pr_pid is present. Reviewed by: kib, emaste (older version) MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D7117 Notes: svn path=/head/; revision=303002
* Include command line arguments in core dump process info.John Baldwin2016-07-141-1/+15
| | | | | | | | | | | Fill in pr_psargs in the NT_PRSINFO ELF core dump note with command line arguments. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D7116 Notes: svn path=/head/; revision=302859
* gcore: Forward pending signals when detaching from the target.Mark Johnston2016-06-241-3/+13
| | | | | | | | | | | | | | Otherwise gcore's ptrace attach operation can race with delivery of a signal and cause it to be lost. In collaboration with: Suraj Raju <sraju@isilon.com> Reviewed by: bdrewery Approved by: re (gjb, kib) MFC after: 2 weeks Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=302179
* Fix buffer overrun in gcore(1) NT_PRPSINFOConrad Meyer2016-05-111-2/+2
| | | | | | | | | | | | | | | | Use size of destination buffer, rather than a constant that may or may not correspond to the source buffer, to restrict the length of copied strings. In particular, pr_fname has 16+1 characters but MAXCOMLEN is 18+1. Use strlcpy instead of strncpy to ensure the result is nul-terminated. This seems to be what is expected of these fields. Reported by: Coverity CIDs: 1011302, 1011378 Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=299458
* Include OBJT_PHYS VM objects in ELF core dumps. In particular thisJohn Baldwin2015-02-141-1/+2
| | | | | | | | | | | | includes the shared page allowing debuggers to use the signal trampoline code to identify signal frames in core dumps. Differential Revision: https://reviews.freebsd.org/D1828 Reviewed by: alc, kib MFC after: 1 week Notes: svn path=/head/; revision=278761
* Make use of the new Altivec ptrace support, to save the Altivec registers inJustin Hibbits2015-01-141-0/+32
| | | | | | | | | | gcore. MFC after: 2 weeks Relnotes: yes Notes: svn path=/head/; revision=277167
* Improve support for XSAVE with debuggers.John Baldwin2014-11-211-0/+35
| | | | | | | | | | | | | | | | | | | | | | - Dump an NT_X86_XSTATE note if XSAVE is in use. This note is designed to match what Linux does in that 1) it dumps the entire XSAVE area including the fxsave state, and 2) it stashes a copy of the current xsave mask in the unused padding between the fxsave state and the xstate header at the same location used by Linux. - Teach readelf() to recognize NT_X86_XSTATE notes. - Change PT_GET/SETXSTATE to take the entire XSAVE state instead of only the extra portion. This avoids having to always make two ptrace() calls to get or set the full XSAVE state. - Add a PT_GET_XSTATE_INFO which returns the length of the current XSTATE save area (so the size of the buffer needed for PT_GETXSTATE) and the current XSAVE mask (%xcr0). Differential Revision: https://reviews.freebsd.org/D1193 Reviewed by: kib MFC after: 2 weeks Notes: svn path=/head/; revision=274817
* Remove an unsed variable.Kevin Lo2014-07-311-1/+1
| | | | Notes: svn path=/head/; revision=269320
* Create 32-bit core files for 32-bit processes on 64-bit machines.Marcel Moolenaar2014-07-261-15/+53
| | | | | | | | | | The 64-bit machine supported right now is amd64, but it's not too hard to add powerpc64. Obtained from: Juniper Networks, Inc. Notes: svn path=/head/; revision=269128
* Wrong cast.Mikolaj Golub2013-04-201-2/+1
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=249704
* Sync gcore(1) with the recent changes in kernel code aimed at addingMikolaj Golub2013-04-201-201/+372
| | | | | | | | | | procstat notes to a process core file. Suggested by: jhb MFC after: 1 month Notes: svn path=/head/; revision=249687
* Match size_t and ssize_t by using %zu and %zd instead of %d.Xin LI2011-07-111-1/+1
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=223924
* Add the ability for GDB to printout the thread name along with otherAttilio Rao2010-11-221-0/+11
| | | | | | | | | | | | | | | | | | | | | | | thread specific informations. In order to do that, and in order to avoid KBI breakage with existing infrastructure the following semantic is implemented: - For live programs, a new member to the PT_LWPINFO is added (pl_tdname) - For cores, a new ELF note is added (NT_THRMISC) that can be used for storing thread specific, miscellaneous, informations. Right now it is just popluated with a thread name. GDB, then, retrieves the correct informations from the corefile via the BFD interface, as it groks the ELF notes and create appropriate pseudo-sections. Sponsored by: Sandvine Incorporated Tested by: gianni Discussed with: dim, kan, kib MFC after: 2 weeks Notes: svn path=/head/; revision=215679
* Fix the way the segments are included in the gcore outputs (with theAttilio Rao2010-07-141-5/+10
| | | | | | | | | | | | | | | | | | | | | | default invokation): - Right now if segments are not writable are not included. Remove this. - Right now if a segment is mapped with NOCORE the check is not honoured. Change this by checking the newly added flag, from libutil, KVME_FLAG_NOCOREDUMP. Besides that, add a new flag (-f) that forces a 'full' dump of all the segments excluding just the malformed ones. This might be used very carefully as, among the reported segments, there could be memory mapped areas that could be vital to program execution. Sponsored by: Sandvine Incorporated Discussed with: kib Reviewed by: emaste Tested by: Sandvine Incorporated MFC after: 2 weeks Notes: svn path=/head/; revision=210063
* Change gcore in order to get rid of the procfs accesses and use FreeBSD'sAttilio Rao2009-11-251-177/+160
| | | | | | | | | | | | | | | | | | | | | | | | specific sysctls and ptrace interfaces. This change switches a bit gcore POLA that is summarized here: - now gcore can recognize threads within the process and handle dumps on thread-scope - the process to be analyzed will be stopped during its gcore run - gcore may not work with processes which are actively being analyzed by gdb or truss - the ptrace interface may cause syscalls to return EINTR, thus interferring with signals handling within the process Side note: <janitor task> the interface can be further lifted in order to get rid of the very last procfs interfaces remnants and made more suitable for copying with sysctl/ptrace interface </janitor task>. Obtained from: Sandvine Incorporated Reviewed by: emaste, rwatson Sponsored by: Sandvine Incorporated MFC: 1 month Notes: svn path=/head/; revision=199805
* Use %zu for size_t, not %zd.Ed Maste2009-09-231-3/+3
| | | | | | | | Submitted by: ru MFC after: 1 week Notes: svn path=/head/; revision=197437
* Use %zd for size_t. With this gcore(1) is WARNS=6 clean.Xin LI2008-07-181-3/+3
| | | | Notes: svn path=/head/; revision=180603
* Eliminate memory leak from an accidental malloc().Ed Maste2007-04-101-1/+0
| | | | Notes: svn path=/head/; revision=168595
* Make gcore(1) 64 bit safe. It was trying to parse the /proc/*/map filePeter Wemm2006-03-251-3/+3
| | | | | | | | | | | | using sscanf and truncating the start/end entries by writing them with a 32 bit int descriptor (%x). The upper bytes of the 64 bit vm_offset_t variables (for little endian machines) were uninitialized. For big endian machines, things would have been worse because it was storing the 32 bit value in the upper half of the 64 bit variable. I've changed it to use %lx and long types. That should work on all our platforms. Notes: svn path=/head/; revision=157109
* Teach gcore about the pathname field of '/proc/*/map' so that it doesn'tRobert Watson2004-07-121-3/+3
| | | | | | | | | | spin when its parser gets confused by a lack of end-of-line. Submitted by: Dan Nelson <dan@dan.emsphone.com> PR: 68839 Notes: svn path=/head/; revision=132047
* Fix some WARNS:David Malone2004-02-151-4/+3
| | | | | | | | | 1) Remove some unused variables. 2) Mark some things aas static or __unused. 3) Cast to make sure we're comparing the same types. Notes: svn path=/head/; revision=125859
* Add #include <sys/queue.h> for sparc64's benefit. The MD includes therePeter Wemm2002-09-131-0/+1
| | | | | | | have less polution. Notes: svn path=/head/; revision=103302
* Use a crowbar to move the a.out code out of gcore.c and into its ownPeter Wemm2002-09-131-1/+21
| | | | | | | | | file so that we have a chance of using gcore on non-i386 platforms. Use linker sets to reduce the registration glue. Remove md-sparc.c, we do not have an a.out sparc32 port. aoutcore.c was repocopied from gcore.c. Notes: svn path=/head/; revision=103299
* Include stdint.h to make this compile.Ian Dowse2002-09-051-0/+1
| | | | | | | Submitted by: Garance A Drosihn <drosih@rpi.edu> Notes: svn path=/head/; revision=102951
* ANSIify function definitions.David Malone2002-09-041-9/+10
| | | | | | | | | | | | Add some constness to avoid some warnings. Remove use register keyword. Deal with missing/unneeded extern/prototypes. Some minor type changes/casts to avoid warnings. Reviewed by: md5 Notes: svn path=/head/; revision=102944
* Add FBSDID. Do not \n terminate err() strings. Spelling.Philippe Charnier2002-03-261-5/+6
| | | | Notes: svn path=/head/; revision=93215
* Removed unused include of kernel-only file <sys/lock.h>.Bruce Evans2001-10-131-1/+0
| | | | Notes: svn path=/head/; revision=84871
* Null terminate buffer.Jonathan Lemon2001-06-071-1/+2
| | | | | | | | | PR: 23150 Submitted by: Dan Nelson <dnelson@emsphone.com> MFC in: 1 week Notes: svn path=/head/; revision=77861
* * include/elf.h has been repo copied to include/elf-hints.h, and it noDavid E. O'Brien2001-05-021-1/+1
| | | | | | | | | | | longer includes machine/elf.h. * consumers of elf.h now use the minimalist elf header possible. This change is motivated by Binutils 2.11.0 and too much clashing over our base elf headers and the Binutils elf headers. Notes: svn path=/head/; revision=76224
* Change our ELF binary branding to something more acceptable to the BinutilsDavid E. O'Brien2000-04-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | maintainers. After we established our branding method of writing upto 8 characters of the OS name into the ELF header in the padding; the Binutils maintainers and/or SCO (as USL) decided that instead the ELF header should grow two new fields -- EI_OSABI and EI_ABIVERSION. Each of these are an 8-bit unsigned integer. SCO has assigned official values for the EI_OSABI field. In addition to this, the Binutils maintainers and NetBSD decided that a better ELF branding method was to include ABI information in a ".note" ELF section. With this set of changes, we will now create ELF binaries branded using both "official" methods. Due to the complexity of adding a section to a binary, binaries branded with ``brandelf'' will only brand using the EI_OSABI method. Also due to the complexity of pulling a section out of an ELF file vs. poking around in the ELF header, our image activator only looks at the EI_OSABI header field. Note that a new kernel can still properly load old binaries except for Linux static binaries branded in our old method. * * For a short period of time, ``ld'' will also brand ELF binaries * using our old method. This is so people can still use kernel.old * with a new world. This support will be removed before 5.0-RELEASE, * and may not last anywhere upto the actual release. My expiration * time for this is about 6mo. * Notes: svn path=/head/; revision=59342
* useracc() the prequel:Poul-Henning Kamp1999-10-291-1/+0
| | | | | | | | | | | | | | Merge the contents (less some trivial bordering the silly comments) of <vm/vm_prot.h> and <vm/vm_inherit.h> into <vm/vm.h>. This puts the #defines for the vm_inherit_t and vm_prot_t types next to their typedefs. This paves the road for the commit to follow shortly: change useracc() to use VM_PROT_{READ|WRITE} rather than B_{READ|WRITE} as argument. Notes: svn path=/head/; revision=52635
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Make gcore work again. It was broken by a format change in theJohn Polstra1999-07-171-2/+2
| | | | | | | | | | | | | procfs map file when object IDs were eliminated in the mega-commit that included procfs_map.c revision 1.19. The map file is a terrible hodge-podge. The fields that are used mainly for kernel debugging should be moved out of it into a separate file, so that the interface presented by the map file to applications can remain stable in the face of VM system changes. Notes: svn path=/head/; revision=48860
* Fix errors detected by -Wformat.John Polstra1998-11-011-2/+3
| | | | Notes: svn path=/head/; revision=40803
* Make gcore work for ELF.John Polstra1998-10-191-0/+513
Notes: svn path=/head/; revision=40525