From: Steffen Dettmer <steffen.dettmer@googlemail.com>
To: gdb@sourceware.org
Subject: Re: gdb "automation" question
Date: Mon, 28 Jun 2010 15:11:00 -0000 [thread overview]
Message-ID: <AANLkTinwuC3Qx6TceKtDvP7sTfVbPpV_EsRkF0SL7uwy@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikDND8rrnJka2vmTCk3avzOPDJhZEdUIEHkkK70@mail.gmail.com>
Hi,
thanks to Tom and others I made progress to automatically display
my remote log messages using python-enabled gdb-7.1.
:-)
Thank you, I have a much better situation now.
However, a bit more tuning would be great :)
First let me summarize what I did:
in C code:
static char *logStaticLogBuffer ...
static void logTrace() { }
at the end of some log function added:
strncat(logStaticLogBuffer, formattedMessage, len);
logTrace(); /* empty function, just to have a symbol to break at */
This can be used with (from `~/.gdbinit')
define show_log
if logStaticLogBuffer != 0 && logStaticLogBuffer[0] != 0
printf "%s", logStaticLogBuffer
set logStaticLogBuffer[0] = 0
end
end
to get it printed right after a record was added (from `~/.gdbinit.py'):
class ShowClogPy (gdb.Function):
"""Shows the static log buffer"""
def __init__ (self):
super (ShowClogPy, self).__init__ ("show_log_py")
def invoke (self):
gdb.execute("show_log")
return False
ShowClogPy()
interactively this can be `enabled' by:
(gdb) break logTrace if $show_log_py()
and this works. My connect command
disable
target remote ...
monitor ...
symbol-file image.elf"
unfortunately must `disable' - otherwise, `target remote' fails with:
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0xd2b44: Unknown error 4294967295.
the error remains for any following commands.
Now my questions how I can improve:
#1 When several messages were printed, I get
---Type <return> to continue, or q <return> to quit---
is there a way to avoid it?
#2 How do I write show_log in Python? According to the online manual
`Python representation of symbols' I understood that I have to
use gdb.lookup_symbol. Is this right? I tried
gdb.lookup_symbol("logStaticLogBuffer")
but this only leads to
AttributeError: 'module' object has no attribute 'lookup_symbol'
#3 my connect command has to disable breakpoints.
I cannot re-enable them, because it does not know which
breakpoints were enabled and which not.
I've read about `save breakpoints' and tried it:
(gdb) i b
Num Type Disp Enb Address What
1 breakpoint keep y 0x000d2b44 in logTrace
at xxx.c:123
stop only if $show_log_py()
(gdb) save breakpoints tmpfile
warning: save-tracepoints: no tracepoints to save.
(gdb) source tmpfile
tmpfile: No such file or directory.
Would `save breakpoints' help to re-enable my breakpoints?
How do I use it correctly?
#4 How do I source ~/.gdbinit.py if and only if I have a python-enabled
gdb?
If not possible:
Would it be an idea for a future version to add such a feature?
#5 How can I automake `break logTrace if $show_log_py()' to be executed
only if
- Python avialable (would be solved by #4)
- symbol logTrace and logStaticLogBuffer both exist
I though I'd need some `if gdb.lookup_symbol("logTrace")',
but failed because of #2
#6 BTW, why does `source ~/.gdbinit.py' work? Is the file name
extension telling that it contains Python syntax?
Otherwise I got errors (and had expected that I have to start
with some `python' command and end with `end').
I'm sorry for my long (and frequent) posting, but I hope to give
all details that could be helpful in case someone finds time to
point me to the right place.
oki,
Steffen
next prev parent reply other threads:[~2010-06-28 15:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-22 14:51 Steffen Dettmer
2010-06-22 16:09 ` Tom Tromey
2010-06-23 17:12 ` Steffen Dettmer
2010-06-23 20:59 ` Tom Tromey
2010-06-23 18:21 ` Steffen Dettmer
2010-06-23 21:01 ` Tom Tromey
2010-06-24 10:33 ` Steffen Dettmer
2010-06-24 18:19 ` Tom Tromey
2010-06-28 15:11 ` Steffen Dettmer [this message]
2010-06-28 15:21 ` Pedro Alves
2010-06-28 20:25 ` Tom Tromey
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=AANLkTinwuC3Qx6TceKtDvP7sTfVbPpV_EsRkF0SL7uwy@mail.gmail.com \
--to=steffen.dettmer@googlemail.com \
--cc=gdb@sourceware.org \
/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