all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* GDB - create buffer to show information about CPU registers
@ 2017-01-25  0:48 Dan Čermák
  2017-01-25  5:16 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Čermák @ 2017-01-25  0:48 UTC (permalink / raw)
  To: help-gnu-emacs


Hi list,

I am currently using Emacs for developing on an embedded ARM CPU and
spend a lot of time debugging it with gdb. I have to frequently check
the contents of CPU registers to find out what went wrong again. Please
note that I am not referring to the 'actual' CPU registers (like r0, r1,
pc, sp, etc) but to memory locations which can be used to get and set
the status of certain components of the CPU. In these typically every
bit has a special meaning (e.g. whether an interrupt flag is set).

My currently biggest issue with my setup is, that to get some
information from a register, I have to print its content with gdb (from
inside Emacs), put that into the mate-calculator to find which bits are
set and which are not and finally open up the datasheet of the CPU and
look up the meaning of each bit.

As you can guess, that is quite tedious and inefficient. Especially
compared to the 'official' IDE provided by the CPU vendor (which is
based on Eclipse), where you can access all CPU registers via a GUI,
which also shows you the value of each bit and its meaning. However, I
don't want to use the Eclipse IDE, since it's a) not Emacs and b) it's
horrendously slow & bloated.

Obviously Emacs cannot provide that out of the box, since it is missing
all the information about the CPU memory. Is anyone aware of a package
that would provide me with such a functionality, where I only have to
add the necessary data about each CPU register? If not, what would you
recommend to use to implement something like in the Eclipse based IDE? I
am unfortunately fairly new to Elisp & Emacs programming, so I have no
clue where to start to extend the functionality.


Thanks in advance for any suggestions,

Dan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB - create buffer to show information about CPU registers
  2017-01-25  0:48 GDB - create buffer to show information about CPU registers Dan Čermák
@ 2017-01-25  5:16 ` Stefan Monnier
  2017-01-25 12:09   ` Skip Montanaro
  2017-01-26 11:42   ` Dan Čermák
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2017-01-25  5:16 UTC (permalink / raw)
  To: help-gnu-emacs

> My currently biggest issue with my setup is, that to get some
> information from a register, I have to print its content with gdb (from
> inside Emacs), put that into the mate-calculator to find which bits are
> set and which are not and finally open up the datasheet of the CPU and
> look up the meaning of each bit.

I don't have a ready-made solution for you, but note that GDB
is scriptable.  If you look at Emacs's src/.gdbinit file
(http://git.savannah.gnu.org/cgit/emacs.git/tree/src/.gdbinit)
you can see what we do to help ourselves debug Emacs's C code.

Note how you can use C-like operations in it, so you could code up some
.gdbinit file for yourself where you write some handy commands that
print the state of your devices's registers in a meaningful manner.

Note that this is a "GDB-only" solution (the only Emacs part of it is
that you got the info in an Emacs discussion group, and that the sample
file provided came from Emacs's source code).


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB - create buffer to show information about CPU registers
  2017-01-25  5:16 ` Stefan Monnier
@ 2017-01-25 12:09   ` Skip Montanaro
  2017-01-26 11:42   ` Dan Čermák
  1 sibling, 0 replies; 6+ messages in thread
From: Skip Montanaro @ 2017-01-25 12:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Note how you can use C-like operations in it, so you could code up some
.gdbinit file for yourself where you write some handy commands that
print the state of your devices's registers in a meaningful manner.


Python comes with a language-specific gdbinit file as well which might be a
source for some ideas:

https://hg.python.org/cpython/file/tip/Misc/gdbinit

Skip Montanaro


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB - create buffer to show information about CPU registers
  2017-01-25  5:16 ` Stefan Monnier
  2017-01-25 12:09   ` Skip Montanaro
@ 2017-01-26 11:42   ` Dan Čermák
  2017-01-26 14:55     ` Augusto Fraga Giachero
  2017-01-27  0:58     ` Stefan Monnier
  1 sibling, 2 replies; 6+ messages in thread
From: Dan Čermák @ 2017-01-26 11:42 UTC (permalink / raw)
  To: help-gnu-emacs


Thanks for the tip, I think that is everything that I need to get
started!

This solution even has the advantage that I can share it with other
users who don't use Emacs but are still using gdb.

Considering a 'less portable' extension: do you happen to know what
would be the easiest way to create a buffer where the evaluation of
these gdb macros would be shown? So basically to have a gui?


Dan

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> My currently biggest issue with my setup is, that to get some
>> information from a register, I have to print its content with gdb (from
>> inside Emacs), put that into the mate-calculator to find which bits are
>> set and which are not and finally open up the datasheet of the CPU and
>> look up the meaning of each bit.
>
> I don't have a ready-made solution for you, but note that GDB
> is scriptable.  If you look at Emacs's src/.gdbinit file
> (http://git.savannah.gnu.org/cgit/emacs.git/tree/src/.gdbinit)
> you can see what we do to help ourselves debug Emacs's C code.
>
> Note how you can use C-like operations in it, so you could code up some
> .gdbinit file for yourself where you write some handy commands that
> print the state of your devices's registers in a meaningful manner.
>
> Note that this is a "GDB-only" solution (the only Emacs part of it is
> that you got the info in an Emacs discussion group, and that the sample
> file provided came from Emacs's source code).
>
>
>         Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB - create buffer to show information about CPU registers
  2017-01-26 11:42   ` Dan Čermák
@ 2017-01-26 14:55     ` Augusto Fraga Giachero
  2017-01-27  0:58     ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Augusto Fraga Giachero @ 2017-01-26 14:55 UTC (permalink / raw)
  To: help-gnu-emacs

I use emacs to do embedded firmware development for ARM Cortex M 
microcontrollers. Recently I've found an interesting python extension 
for gdb that uses the SVD (System View Description) files provided by 
the manufacturer: https://github.com/Palmitoxico/PyCortexMDebug (my 
patched version, the original repository is 
https://github.com/bnahill/PyCortexMDebug).
You can find the respective SVD file for your microcontroller here: 
https://github.com/posborne/cmsis-svd.

This extension provides detailed information of the peripheral's 
registers at the bit level. For now it can't write to the registers, but 
this functionality may be added in the future.



On 26-01-2017 09:42, Dan Čermák wrote:
> Thanks for the tip, I think that is everything that I need to get
> started!
>
> This solution even has the advantage that I can share it with other
> users who don't use Emacs but are still using gdb.
>
> Considering a 'less portable' extension: do you happen to know what
> would be the easiest way to create a buffer where the evaluation of
> these gdb macros would be shown? So basically to have a gui?
>
>
> Dan
>
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>> My currently biggest issue with my setup is, that to get some
>>> information from a register, I have to print its content with gdb (from
>>> inside Emacs), put that into the mate-calculator to find which bits are
>>> set and which are not and finally open up the datasheet of the CPU and
>>> look up the meaning of each bit.
>> I don't have a ready-made solution for you, but note that GDB
>> is scriptable.  If you look at Emacs's src/.gdbinit file
>> (http://git.savannah.gnu.org/cgit/emacs.git/tree/src/.gdbinit)
>> you can see what we do to help ourselves debug Emacs's C code.
>>
>> Note how you can use C-like operations in it, so you could code up some
>> .gdbinit file for yourself where you write some handy commands that
>> print the state of your devices's registers in a meaningful manner.
>>
>> Note that this is a "GDB-only" solution (the only Emacs part of it is
>> that you got the info in an Emacs discussion group, and that the sample
>> file provided came from Emacs's source code).
>>
>>
>>          Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GDB - create buffer to show information about CPU registers
  2017-01-26 11:42   ` Dan Čermák
  2017-01-26 14:55     ` Augusto Fraga Giachero
@ 2017-01-27  0:58     ` Stefan Monnier
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2017-01-27  0:58 UTC (permalink / raw)
  To: help-gnu-emacs

> Considering a 'less portable' extension: do you happen to know what
> would be the easiest way to create a buffer where the evaluation of
> these gdb macros would be shown? So basically to have a gui?

You can use GDB's `display` command for that.


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-27  0:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-25  0:48 GDB - create buffer to show information about CPU registers Dan Čermák
2017-01-25  5:16 ` Stefan Monnier
2017-01-25 12:09   ` Skip Montanaro
2017-01-26 11:42   ` Dan Čermák
2017-01-26 14:55     ` Augusto Fraga Giachero
2017-01-27  0:58     ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.