From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103700 invoked by alias); 19 Oct 2015 11:33:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 103690 invoked by uid 89); 19 Oct 2015 11:33:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: e28smtp05.in.ibm.com Received: from e28smtp05.in.ibm.com (HELO e28smtp05.in.ibm.com) (122.248.162.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 19 Oct 2015 11:33:36 +0000 Received: from /spool/local by e28smtp05.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 Oct 2015 17:03:31 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp05.in.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 19 Oct 2015 17:03:28 +0530 X-MailFrom: sangamesh.swamy@in.ibm.com X-RcptTo: gdb-patches@sourceware.org Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 25418E0062 for ; Mon, 19 Oct 2015 17:03:29 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay03.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9JBXLOT50528424 for ; Mon, 19 Oct 2015 17:03:21 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9JBWJFK026575 for ; Mon, 19 Oct 2015 17:02:19 +0530 Received: from d23ml178.in.ibm.com (d23ml178.in.ibm.com [9.182.8.68]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t9JBWI95026537 for ; Mon, 19 Oct 2015 17:02:18 +0530 To: gdb-patches@sourceware.org MIME-Version: 1.0 Subject: core file support for AIX X-KeepSent: 8F4A8FA0:A9E5B5DA-65257EE3:003F3BB0; type=4; name=$KeepSent From: Sangamesh Mallayya Message-ID: Date: Mon, 19 Oct 2015 11:33:00 -0000 Content-Type: multipart/mixed; boundary="=_mixed 003F5E6665257EE3_=" X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15101911-0017-0000-0000-000007E09295 X-SW-Source: 2015-10/txt/msg00333.txt.bz2 --=_mixed 003F5E6665257EE3_= Content-Type: text/plain; charset="US-ASCII" Content-length: 3268 Hi All, Below patches adds support for debugging core file's in AIX. Right now gdb doesn't recognise the AIX core file and doesn't have method to identify if we are using old format or new core format. These patch adds support for debugging both 32-bit & 64-bit core file in case of both 32-bit and 64-bit gdb. 1) With the first patch (core_patch.txt) we resolve these errors is not a core dump: File format not recognized And also the compilation error like this after adding powerpc64 entry in configuration file. rs6000-core.c:112: error: field 'old' has incomplete type rs6000-core.c:125: error: field 'old' has incomplete type rs6000-core.c: In function 'read_hdr': rs6000-core.c:286: error: dereferencing pointer to incomplete type rs6000-core.c:286: error: dereferencing pointer to incomplete type Here is sample example to test this. # cat test.c int foo(char **p) { strcpy(*p, "Hello"); } int main() { char *p; foo(&p); } # file test_32 core test_32: executable (RISC System/6000 V3.1) or obj module not stripped core: AIX core file 32-bit, test_32 Program terminated with signal 11, Segmentation fault. #0 0x0000f014 in ?? () (gdb) bt #0 0x0000f014 in ?? () #1 0x10000390 in foo (p=0x2ff22bf8) at test.c:3 #2 0x100003e4 in main () at test.c:9 (gdb) frame 1 #1 0x10000390 in foo (p=0x2ff22bf8) at test.c:3 3 strcpy(*p, "Hello"); # file test_64 core test_64: 64-bit XCOFF executable or object module core: AIX core file 64-bit, test_64 Program terminated with signal 11, Segmentation fault. #0 0x000000000000f414 in ?? () (gdb) bt #0 0x000000000000f414 in ?? () #1 0x0000000100000490 in foo (p=0xffffffffffffb00) at test.c:3 #2 0x00000001000004e4 in main () at test.c:9 (gdb) frame 1 #1 0x0000000100000490 in foo (p=0xffffffffffffb00) at test.c:3 3 strcpy(*p, "Hello"); (gdb) 2) Second patch(core_bmax_patch.txt) adds the support for debugging core file generated by binaries in case of the large memory model. If a binary has been compiled with -bmaxdata option then we can't be able access the value stored in .data section xlc -g -o test test.c -bmaxdata:0x80000000 (gdb) bt #0 0xd013a820 in raise () from /usr/lib/libc.a(shr.o) #1 0xd01b3088 in abort () from /usr/lib/libc.a(shr.o) #2 0x100003b8 in main () at test.c:7 (gdb) frame 2 #2 0x100003b8 in main () at test.c:7 7 test.c: A file or directory in the path name does not exist.. (gdb) info locals c = 0x30000a68 __func__ = "main" (gdb) with fix (gdb) bt #0 0xd013a820 in raise () from /usr/lib/libc.a(shr.o) #1 0xd01b3088 in abort () from /usr/lib/libc.a(shr.o) #2 0x100003b8 in main () at test.c:7 (gdb) frame 2 #2 0x100003b8 in main () at test.c:7 7 test.c: A file or directory in the path name does not exist.. (gdb) info locals c = 0x30000a68 "Hello" __func__ = "main" (gdb) Thanks & Regards, -Sangamesh AIX BOS Development Bangalore, EGL D Block, 6th floor Phone: +91 (80) 417-76965 --=_mixed 003F5E6665257EE3_= Content-Type: application/octet-stream; name="bfd_ChangeLog" Content-Disposition: attachment; filename="bfd_ChangeLog" Content-Transfer-Encoding: base64 Content-length: 1107 CSogY29uZmlndXJlIChwb3dlcnBjNjQtKi1haXhbNS05XS4qKTogTWF0Y2gg cG93ZXJwYzY0IHJ1bm5pbmcgYWl4IGZvciBjb3JlIGZpbGUgc3VwcG9ydAoK CSogcnM2MDAwLWNvcmUuYzogQ2hlY2sgZm9yIF9fbGRfaW5mbzY0IGlmIGNv bXBpbGluZyA2NC1iaXQgZ2RiLgoJQWRkZWQgQkZENjQgY2hlY2sgaWYgd2Ug YXJlIHVzaW5nIG9sZCBjb3JlIGZpbGUgZm9ybWF0IGZvciAzMi1iaXQgZ2Ri LgoJU2V0IHNpemVvZiBDT1JFX0NPTU1PTlNaIGFwcHJvcHJpYXRlbHkgaW4g Y2FzZSBvZiBlaXRoZXIgbmV3IG9yIG9sZCBjb3JlIGZpbGUgZm9ybWF0LgoJ KHJlYWRfaGRyKTogQWRkZWQgQkZENjQgY2hlY2sgZm9yIDY0LWJpdCBzdXBw b3J0LgoJKHJzNjAwMGNvZmZfY29yZV9wKTogTGlrZXdpc2UuCgkocnM2MDAw Y29mZl9jb3JlX2ZpbGVfbWF0Y2hlc19leGVjdXRhYmxlX3ApOiBMaWtld2lz ZS4KCShyczYwMDBjb2ZmX2NvcmVfZmlsZV9mYWlsaW5nX2NvbW1hbmQpOiBM aWtld2lzZS4KCShyczYwMDBjb2ZmX2NvcmVfZmlsZV9mYWlsaW5nX3NpZ25h bCk6IExpa2V3aXNlLgoJCgkqIHJzNjAwMC1jb3JlLmM6IEFkZCBzdXBwb3J0 IGZvciBkZWJ1Z2dpbmcgY29yZSBmaWxlcyBnZW5lcmF0ZWQgYnkgYmluYXJp ZXMgaW4gTGFyZ2UgTWVtb3J5IG1vZGVsLgoJKHJzNjAwMGNvZmZfY29yZV9w KTogSWYgTGFyZ2UgTWVtb3J5IE1vZGVsIGlzIHVzZWQsIHRoZW4gdGhlIC5k YXRhIHNlZ21lbnQgc2hvdWxkIHN0YXJ0IGZyb20KICAgIEJEQVRBT1JHIHdo aWNoIGhhcyBiZWVuIGRlZmluZWQgaW4gdGhlIHN5c3RlbSBoZWFkZXIgZmls ZXMuCg== --=_mixed 003F5E6665257EE3_= Content-Type: text/plain; name="core_bmax_patch.txt" Content-Disposition: attachment; filename="core_bmax_patch.txt" Content-Transfer-Encoding: quoted-printable Content-length: 1358 --- bfd/rs6000-core.c_orig 2015-10-16 13:07:20.000000000 -0500 +++ bfd/rs6000-core.c 2015-10-19 04:26:17.000000000 -0500 @@ -528,6 +528,7 @@ rs6000coff_core_p (bfd *abfd) file_ptr ldi_core; uint ldi_next; bfd_vma ldi_dataorg; + bfd_vma core_dataorg; =20 /* Fields from new and old core structures. */ bfd_size_type c_datasize, c_vmregions; @@ -551,19 +552,27 @@ rs6000coff_core_p (bfd *abfd) /* .data section from executable. */ if (c_datasize) { + /* If Large Memory Model is used, then the .data segment should start from + BDATAORG which has been defined in the system header files. */ + + if (c_flag & CORE_BIGDATA) + core_dataorg =3D BDATAORG; + else + core_dataorg =3D CDATA_ADDR (c_datasize); + if (!make_bfd_asection (abfd, ".data", SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS, c_datasize, - (bfd_vma) CDATA_ADDR (c_datasize), + (bfd_vma) core_dataorg, c_data)) goto fail; } =20 /* .data sections from loaded objects. */ if (proc64) - size =3D (int) ((LdInfo *) 0)->l64.ldinfo_filename; + size =3D (unsigned long) ((LdInfo *) 0)->l64.ldinfo_filename; else - size =3D (int) ((LdInfo *) 0)->l32.ldinfo_filename; + size =3D (unsigned long) ((LdInfo *) 0)->l32.ldinfo_filename; =20 while (1) { --=_mixed 003F5E6665257EE3_= Content-Type: text/plain; name="core_patch.txt" Content-Disposition: attachment; filename="core_patch.txt" Content-Transfer-Encoding: quoted-printable Content-length: 7018 --- bfd/configure_orig 2015-10-16 10:03:17.000000000 -0500 +++ bfd/configure 2015-10-16 10:12:51.000000000 -0500 @@ -14056,7 +14056,7 @@ if test "${target}" =3D "${host}"; then rs6000-*-lynx*) COREFILE=3Dlynx-core.lo ;; - rs6000-*-aix[5-9].* | powerpc-*-aix[5-9].*) + rs6000-*-aix[5-9].* | powerpc-*-aix[5-9].* | powerpc64-*-aix[5-9].*) COREFILE=3Drs6000-core.lo COREFLAG=3D"$COREFLAG -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE" ;; @@ -14094,6 +14094,7 @@ rm -f core conftest.err conftest.$ac_obj rs6000-*-*) COREFILE=3Drs6000-core.lo ;; powerpc-*-aix4*) COREFILE=3Drs6000-core.lo ;; powerpc-*-aix*) COREFILE=3Drs6000-core.lo ;; + powerpc64-*-aix*) COREFILE=3Drs6000-core.lo ;; powerpc-*-beos*) ;; powerpc-*-freebsd* | powerpc-*-kfreebsd*-gnu) COREFILE=3D'' ;; --- bfd/rs6000-core.c_orig 2015-10-16 13:07:20.000000000 -0500 +++ bfd/rs6000-core.c 2015-10-19 04:23:26.000000000 -0500 @@ -92,7 +92,7 @@ typedef unsigned long ptr_to_uint; /* Union of 32-bit and 64-bit versions of ld_info. */ =20 typedef union { -#ifdef __ld_info32 +#if defined (__ld_info32) || defined (__ld_info64) struct __ld_info32 l32; struct __ld_info64 l64; #else @@ -109,8 +109,10 @@ typedef union { #else struct core_dump new_dump; /* for simpler coding */ #endif +#ifndef BFD64 /* use old only if gdb is 32-bit */ struct core_dump old; /* old AIX 4.2- core dump, still used on 4.3+ with appropriate SMIT config */ +#endif } CoreHdr; =20 /* Union of old and new vm_info structures. */ @@ -122,14 +124,20 @@ typedef union { #else struct vm_info new_dump; #endif +#ifndef BFD64 struct vm_info old; +#endif } VmInfo; #endif =20 /* Return whether CoreHdr C is in new or old format. */ =20 #ifdef AIX_CORE_DUMPX_CORE -# define CORE_NEW(c) (!(c).old.c_entries) + #ifndef BFD64 + # define CORE_NEW(c) (!(c).old.c_entries) + #else + # define CORE_NEW(c) (!(c).new_dump.c_entries) + #endif #else # define CORE_NEW(c) 0 #endif @@ -258,9 +266,13 @@ typedef union { =20 /* Size of the leading portion that old and new core dump structures have = in common. */ -#define CORE_COMMONSZ ((int) &((struct core_dump *) 0)->c_entries \ - + sizeof (((struct core_dump *) 0)->c_entries)) - +#ifdef AIX_CORE_DUMPX_CORE +#define CORE_COMMONSZ ((long) &((struct core_dumpx *) 0)->c_entries \ + + sizeof (((struct core_dumpx *) 0)->c_entries)) +#else +#define CORE_COMMONSZ ((int) &((struct core_dump *) 0)->c_entries \ + + sizeof (((struct core_dump *) 0)->c_entries) +#endif /* Define prototypes for certain functions, to avoid a compiler warning saying that they are missing. */ =20 @@ -290,8 +302,10 @@ read_hdr (bfd *abfd, CoreHdr *core) /* Read the trailing portion of the structure. */ if (CORE_NEW (*core)) size =3D sizeof (core->new_dump); + #ifndef BFD64 else size =3D sizeof (core->old); + #endif size -=3D CORE_COMMONSZ; return bfd_bread ((char *) core + CORE_COMMONSZ, size, abfd) =3D=3D size; } @@ -356,6 +370,7 @@ rs6000coff_core_p (bfd *abfd) c_stackend =3D CNEW_STACKORG (core.new_dump) + c_size; c_lsize =3D CNEW_LSIZE (core.new_dump); c_loader =3D CNEW_LOADER (core.new_dump); + #ifndef BFD64 proc64 =3D CNEW_PROC64 (core.new_dump); } else @@ -366,6 +381,7 @@ rs6000coff_core_p (bfd *abfd) c_stackend =3D COLD_STACKEND; c_lsize =3D 0x7ffffff; c_loader =3D (file_ptr) (ptr_to_uint) COLD_LOADER (core.old); + #endif proc64 =3D 0; } =20 @@ -379,11 +395,13 @@ rs6000coff_core_p (bfd *abfd) c_regsize =3D sizeof (CNEW_MSTSAVE (core.new_dump)); c_regptr =3D &CNEW_MSTSAVE (core.new_dump); } + #ifndef BFD64 else { c_regsize =3D sizeof (COLD_MSTSAVE (core.old)); c_regptr =3D &COLD_MSTSAVE (core.old); } + #endif c_regoff =3D (char *) c_regptr - (char *) &core; =20 if (bfd_stat (abfd, &statbuf) < 0) @@ -433,7 +451,11 @@ rs6000coff_core_p (bfd *abfd) } =20 /* Sanity check on the c_tab field. */ + #ifndef BFD64 if (!CORE_NEW (core) && (c_loader < (file_ptr) sizeof core.old || + #else + if (!CORE_NEW (core) && (c_loader < (file_ptr) sizeof core.new_dump || + #endif c_loader >=3D statbuf.st_size || c_loader >=3D c_stack)) { @@ -447,7 +469,11 @@ rs6000coff_core_p (bfd *abfd) bfd_get_filename (abfd)); =20 /* Allocate core file header. */ + #ifndef BFD64 size =3D CORE_NEW (core) ? sizeof (core.new_dump) : sizeof (core.old); + #else + size =3D sizeof (core.new_dump); + #endif tmpptr =3D (char *) bfd_zalloc (abfd, (bfd_size_type) size); if (!tmpptr) return NULL; @@ -540,6 +566,7 @@ rs6000coff_core_p (bfd *abfd) c_vmregions =3D core.new_dump.c_vmregions; c_vmm =3D (file_ptr) core.new_dump.c_vmm; } + #ifndef BFD64 else { c_datasize =3D core.old.c_datasize; @@ -547,6 +574,7 @@ rs6000coff_core_p (bfd *abfd) c_vmregions =3D core.old.c_vmregions; c_vmm =3D (file_ptr) (ptr_to_uint) core.old.c_vmm; } + #endif =20 /* .data section from executable. */ if (c_datasize) @@ -613,7 +641,11 @@ rs6000coff_core_p (bfd *abfd) file_ptr vminfo_offset; bfd_vma vminfo_addr; =20 + #ifndef BFD64 size =3D CORE_NEW (core) ? sizeof (vminfo.new_dump) : sizeof (vminfo.= old); + #else + size =3D sizeof (vminfo.new_dump); + #endif if (bfd_bread (&vminfo, size, abfd) !=3D size) goto fail; =20 @@ -623,12 +655,14 @@ rs6000coff_core_p (bfd *abfd) vminfo_size =3D vminfo.new_dump.vminfo_size; vminfo_offset =3D vminfo.new_dump.vminfo_offset; } + #ifndef BFD64 else { vminfo_addr =3D (bfd_vma) (ptr_to_uint) vminfo.old.vminfo_addr; vminfo_size =3D vminfo.old.vminfo_size; vminfo_offset =3D vminfo.old.vminfo_offset; } + #endif =20 if (vminfo_offset) if (!make_bfd_asection (abfd, ".vmdata", @@ -668,8 +702,10 @@ rs6000coff_core_file_matches_executable_ =20 if (CORE_NEW (core)) c_loader =3D CNEW_LOADER (core.new_dump); + #ifndef BFD64 else c_loader =3D (file_ptr) (ptr_to_uint) COLD_LOADER (core.old); + #endif =20 if (CORE_NEW (core) && CNEW_PROC64 (core.new_dump)) size =3D (int) ((LdInfo *) 0)->l64.ldinfo_filename; @@ -732,8 +768,12 @@ char * rs6000coff_core_file_failing_command (bfd *abfd) { CoreHdr *core =3D core_hdr (abfd); + #ifndef BFD64 char *com =3D CORE_NEW (*core) ? CNEW_COMM (core->new_dump) : COLD_COMM (core->old); + #else + char *com =3D CNEW_COMM (core->new_dump); + #endif =20 if (*com) return com; @@ -745,7 +785,11 @@ int rs6000coff_core_file_failing_signal (bfd *abfd) { CoreHdr *core =3D core_hdr (abfd); + #ifndef BFD64 return CORE_NEW (*core) ? core->new_dump.c_signo : core->old.c_signo; + #else + return core->new_dump.c_signo; + #endif } =20 #endif /* AIX_CORE */ --=_mixed 003F5E6665257EE3_=--