From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76374 invoked by alias); 28 Sep 2016 13:31:00 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 76348 invoked by uid 89); 28 Sep 2016 13:30:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=adaptation, Hx-spam-relays-external:15.1.466.34, H*RU:15.1.466.34, H*r:ip*15.1.466.34 X-HELO: mx5.ptsecurity.com Received: from mx5.ptsecurity.com (HELO mx5.ptsecurity.com) (45.58.112.35) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Sep 2016 13:30:53 +0000 Received: from dc1-mail-01.ptsecurity.ru (10.0.52.111) by ny-mx-01.ptsecurity.ru (10.6.20.6) with Microsoft SMTP Server (TLS) id 15.1.466.34; Wed, 28 Sep 2016 16:30:50 +0300 Received: from [10.0.72.136] (10.0.72.136) by dc1-mail-01.ptsecurity.ru (10.0.52.111) with Microsoft SMTP Server (TLS) id 15.1.466.34; Wed, 28 Sep 2016 16:30:49 +0300 From: Nikolay Martyanov Subject: Custom core file To: Message-ID: Date: Wed, 28 Sep 2016 13:31:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dc1-mail-01.ptsecurity.ru (10.0.52.111) To dc1-mail-01.ptsecurity.ru (10.0.52.111) X-SW-Source: 2016-09/txt/msg00065.txt.bz2 Hello guys! I have a self-written bare-metal hypervisor for x86 arch and I'd like to perform postmortem debugging of it's core (not VM, hypervisor itself!). So the idea is to save physical memory state and later use GDB to interpret it. As I understand, GDB can interpret only `core files`. But I didn't found a lot of info about this file format. Some sources say it should be a specific ELF file with several mandatory ".note" sections. Others say `core file` can be in any format and adaptation should be done on BFD-level of GDB. I looked through the code in corelow.c. Now my undestanding is somthing like: 1. Save data section of my hypervisor 2. Save current stack state of my hypervisor 3. Save current registers state (MSR?) 4. Define "sys/user.h"-like header with layout description of above mentioned structures 5. Using this header, implement function analog to `trad_unix_core_file_p()` in file analog to `trad-core.c` (It translates my `struct user` to `struct trad_core_struct`) 6. Implement functions like `supply_*regset()` in file like `i386-myhyper-nat.c` 7. ??? (magic I didn't realized yet) 8. Profit! Note, steps 1-3 say nothing about ELF-format. It embarrasses me... So my question is: am I looking in a right direction? Can you point me in to the issues in the plan (or even my understanding)? Or may be there are any other ways to feed a raw physical memory to GDB? Thanks, Nikolay