From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15379 invoked by alias); 10 May 2009 19:21:42 -0000 Received: (qmail 15371 invoked by uid 22791); 10 May 2009 19:21:41 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 10 May 2009 19:21:37 +0000 Received: (qmail 11505 invoked from network); 10 May 2009 19:21:32 -0000 Received: from unknown (HELO orlando) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 10 May 2009 19:21:32 -0000 From: Pedro Alves To: danny.backx@scarlet.be Subject: Re: Post mortem debugging for Windows CE Date: Sun, 10 May 2009 19:21:00 -0000 User-Agent: KMail/1.9.10 Cc: gdb-patches@sourceware.org References: <1240929901.29047.110.camel@dannypc> <200905062148.03196.pedro@codesourcery.com> <1241659264.4083.268.camel@dannypc> In-Reply-To: <1241659264.4083.268.camel@dannypc> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200905102021.31156.pedro@codesourcery.com> X-IsSubscribed: yes 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 X-SW-Source: 2009-05/txt/msg00197.txt.bz2 On Thursday 07 May 2009 02:21:04, Danny Backx wrote: > On Wed, 2009-05-06 at 21:48 +0100, Pedro Alves wrote: > > A few suggestions: > > > > - Please forgive me if you know this already. > > Your minidump bfd code should work on all hosts, 64-bit, 32-bit, > > big endian or little endian. This means that code like: > [..] > > ... is unacceptable. You need to use the bfd_get_32 and friends > > to parse the data on the file. > > I'll start doing all that. I didn't know about avoiding structs so > this'll be some work. > > Should they be avoided completely ? I wrote code like the snippet below. > Should the sizeof (CEDUMP_THREAD_CALL_STACK_LIST) be replaced ? Should > the struct definitions be gone completely, or still be there in > comment ? Take a look at src/include/coff/external.h and src/include/coff/internal.h, or grep for Internal and External in src/include/elf/, or grep for "swap" in bfd. The external variants are the ones that are read out of file. The internal variants are the ones used internally. Presumably, you won't have that much code, so you may chose to always use "external" types, and extract the fields with bfd_get_foo. > Also this'll work for CE based minidumps now, not the ones from desktop > Windows. This may be as simple as getting the code to handle not only > the > ceStreamThreadCallStackList = 0x8007 > but also the desktop value. But life is usually not that simple. If this is not useful to you, then you don't have to implement it. I'm sure someone else having an interest in desktop Windows will take of adding such functionality. > rva = minidump_core_locate_stream(abfd, ceStreamThreadCallStackList); > if (bfd_seek (abfd, (file_ptr) rva, SEEK_SET) != 0) > return; > nread = bfd_bread (&tcsl, (bfd_size_type) sizeof > (CEDUMP_THREAD_CALL_STACK_LIST), abfd); > if (nread != sizeof (CEDUMP_THREAD_CALL_STACK_LIST)) > { > if (bfd_get_error () != bfd_error_system_call) > bfd_set_error (bfd_error_wrong_format); > return; > } > > /* > * Need to read all the CEDUMP_THREAD_CALL_STACK entries, > * they're just after the CEDUMP_THREAD_CALL_STACK_LIST. > * The CEDUMP_THREAD_CALL_STACK_FRAME fields are in potentially other > places though. > * So allocate space for enough CEDUMP_THREAD_CALL_STACK_LIST entries. > */ > sz = tcsl.NumberOfEntries * sizeof(CEDUMP_THREAD_CALL_STACK); Right, this is exactly what you should *not* do. That 'tcsl.NumberOfEntries' field will return garbage if e.g., the host machine running gdb is big endian, while the minidump data is supposedly stored in little endian (ARM). Same for hidden padding the compiler may insert in the structure, influencing the tcsl fields offsets, and the size of the structure in the view of the host. -- Pedro Alves