public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Duane Ellis <duane@duaneellis.com>
To: Juha Aaltonen <turbopultti@gmail.com>
Cc: gdb-mailing list <gdb@sourceware.org>
Subject: Re: Bare metal "server" - cleaning up after a program
Date: Thu, 08 Oct 2015 22:59:00 -0000	[thread overview]
Message-ID: <C09C17CA-5AC2-4212-B6B3-A1DAE7A68DB7@duaneellis.com> (raw)
In-Reply-To: <CAHR0xd4Otr2YPgKgaJqmRmk-7+68oyx+YSAbeRk+3q-4wZETYQ@mail.gmail.com>

>> Gdb seems so focused to debugging processes running within an OS, that
>> "interpretation" in context of bare metal environment is hard.

Bingo - you hit the problem nail on the head, bullseye!

you also need to consider the situation when you want to “hot-attach” to a running process.
perhaps your target is hung… and you want to attach to see *why is this thing dead?”
or perhaps - where is this thing at?

You might want to consider this to solve certain other problems:

Use GDB-Python extensions
	Then - using Python, create your own new GDB commands.
	These commands - effectively send a GDB Remote packet to your gdb server

GDB Python is enabled by default on Linux (Linaro GDB releases)
And - latest release of (windows binary) Linaro GDB includes GDB Python [previously it was not enabled on windows]
The ARM Embedded GDB (windows binary) already had this feature enabled.
	
What i mean is this:  
	Using Python, you can create any new GDB command
	Using python, you can execute any arbitrary GDB command,
	specifically the special maintenance command that lets you send an arbitrary packet
	You can also get the RESULT of that arbitrary [packet] command.

	You then your python module must take apart the ascii text the reply.. 

What would be better is this

	If GDB-Python exposed a “remote” object that let you execute the REMOTE commands more generally
	It’s sort of a pain to “printf()” your command into an ascii command line.
	Stuff the ascii command line into GDB
	Capture the output ascii text
	Then covert this ascii text back into Binary data.
	 (GDB need to expose more in the python area)
	Perhaps in the future, things will be better

	meanwhile - you do it they way I describe

Why is this important?

	This lets you create any new command in GDB, that can do *anything* you need in your bare metal target.

For example, you want to read/write  CP14/CP15 register  values?
	Your python script could clean up the MMU configuration
	or - perhaps Dump MMU mapping tables.

In future you could extend this to create a command called:  “mmu-dump”  or    “mmu-explain ADDRESS” 
These would use MCR/MRC instructions to read the MMU config registers, then access the MMU page tables
and perhaps dump the mmu configuration, and/or translate a virtual address to a physical address.

In your case - launching a new application

Once your GDB-Python script has done what it needs to do (i.e.: Reconfigure, reset the target) you can use the normal “load” commands to load your image.

-Duane.


  parent reply	other threads:[~2015-10-08 22:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08 22:27 Juha Aaltonen
2015-10-08 22:40 ` Juha Aaltonen
2015-10-08 22:59 ` Duane Ellis [this message]
2015-10-09  9:26 ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C09C17CA-5AC2-4212-B6B3-A1DAE7A68DB7@duaneellis.com \
    --to=duane@duaneellis.com \
    --cc=gdb@sourceware.org \
    --cc=turbopultti@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).