Proposed enhancement to RDA, the remote debug agent

Michael Snyder
2002-11-22T19:10:23Z

[-- Attachment #1: Type: text/plain, Size: 898 bytes --]

Hello,

I'm looking for feedback, mostly on my infrastructure approach for
the following addition to RDA. In one sentence, I'm going to add
introspect support.

The diff below probably won't apply cleanly, but will convey the
sense of my proposed first-step.

Basically, I'll add a new subdirectory rda/introspect, and tweak
the top-level rda makefile and configure to include it. I'll make
the top-level remote protocol parser recognize the 'Q' and 'q' msgs
that implement introspect, and have it call functions that do all
the work. Then I'll implement two separate libraries in the
introspect directory -- one that simply provides empty stubs to
satisfy those calls (for targets that don't implement introspect),
and a second that actually implements introspect.

The first check-in will include only the dummy library.

Anybody suggest any improvements to this approach?

Thanks,
Michael

[-- Attachment #2: introspect.diff --]
[-- Type: text/plain, Size: 16216 bytes --]

diff -rpN rda/Makefile.am rda.snap1/Makefile.am
*** rda/Makefile.am Tue Aug 27 18:22:27 2002
--- rda.snap1/Makefile.am Wed Nov 20 11:51:32 2002
*************** WERROR_CFLAGS = @WERROR_CFLAGS@
*** 7,11 ****
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)

APPL_DIRS = @targ_subdirs@
! SUBDIRS = lib samples qe $(APPL_DIRS)

--- 7,11 ----
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)

APPL_DIRS = @targ_subdirs@
! SUBDIRS = lib introspect samples qe $(APPL_DIRS)

diff -rpN rda/Makefile.in rda.snap1/Makefile.in
*** rda/Makefile.in Mon Nov 4 10:48:56 2002
--- rda.snap1/Makefile.in Wed Nov 20 11:51:59 2002
*************** AUTOMAKE_OPTIONS = foreign
*** 119,125 ****
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)

APPL_DIRS = @targ_subdirs@
! SUBDIRS = lib samples qe $(APPL_DIRS)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
--- 119,125 ----
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)

APPL_DIRS = @targ_subdirs@
! SUBDIRS = lib introspect samples qe $(APPL_DIRS)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
diff -rpN rda/configure rda.snap1/configure
*** rda/configure Mon Nov 4 10:48:56 2002
--- rda.snap1/configure Wed Nov 20 12:17:17 2002
*************** targ_subdirs=
*** 4723,4729 ****

case "$target" in
! *linux*) targ_subdirs="$targ_subdirs unix" ;;
esac

--- 4723,4729 ----

case "$target" in
! *linux*) targ_subdirs="$targ_subdirs introspect unix" ;;
esac

*************** echo "${ECHO_T}found xgettext programs i
*** 5448,5454 ****

! ac_config_files="$ac_config_files Makefile lib/Makefile samples/Makefile qe/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
--- 5448,5454 ----

! ac_config_files="$ac_config_files Makefile lib/Makefile samples/Makefile qe/Makefile introspect/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
*************** do
*** 5948,5953 ****
--- 5948,5954 ----
"lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
"samples/Makefile" ) CONFIG_FILES="$CONFIG_FILES samples/Makefile" ;;
"qe/Makefile" ) CONFIG_FILES="$CONFIG_FILES qe/Makefile" ;;
+ "introspect/Makefile" ) CONFIG_FILES="$CONFIG_FILES introspect/Makefile" ;;
"depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
diff -rpN rda/configure.in rda.snap1/configure.in
*** rda/configure.in Tue Aug 27 18:22:27 2002
--- rda.snap1/configure.in Wed Nov 20 12:17:05 2002
*************** targ_subdirs=
*** 90,96 ****

case "$target" in
! *linux*) targ_subdirs="$targ_subdirs unix" ;;
esac

--- 90,96 ----

case "$target" in
! *linux*) targ_subdirs="$targ_subdirs introspect unix" ;;
esac

*************** AC_SUBST(targ_subdirs)
*** 104,107 ****
CY_WITH_NLS

dnl Outputs
! AC_OUTPUT(Makefile lib/Makefile samples/Makefile qe/Makefile)
--- 104,107 ----
CY_WITH_NLS

dnl Outputs
! AC_OUTPUT(Makefile lib/Makefile samples/Makefile qe/Makefile introspect/Makefile)
diff -rpN rda/include/gdbtrace.h rda.snap1/include/gdbtrace.h
*** rda/include/gdbtrace.h Wed Dec 31 16:00:00 1969
--- rda.snap1/include/gdbtrace.h Wed Nov 20 17:05:32 2002
***************
*** 0 ****
--- 1,38 ----
+ /* trace-dummy.c
+
+ Copyright 2000, 2001, 2002 Red Hat, Inc.
+
+ This file is part of RDA, the Red Hat Debug Agent (and library).
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Alternative licenses for RDA may be arranged by contacting Red Hat,
+ Inc. */
+
+ /*
+ * Global interface to introspect trace agent.
+ */
+
+ extern void gdbtrace_status_query (struct gdbserv *);
+ extern void gdbtrace_limit_query (struct gdbserv *);
+ extern void gdbtrace_buffer_query (struct gdbserv *);
+ extern void gdbtrace_init (struct gdbserv *);
+ extern void gdbtrace_start (struct gdbserv *);
+ extern void gdbtrace_stop (struct gdbserv *);
+ extern void gdbtracepoint_define (struct gdbserv *);
+ extern void gdbtrace_frame_select (struct gdbserv *);
+ extern void gdbtrace_limit_set (struct gdbserv *);
+ extern void gdbtrace_buffer_set (struct gdbserv *);
diff -rpN rda/introspect/ChangeLog rda.snap1/introspect/ChangeLog
*** rda/introspect/ChangeLog Wed Dec 31 16:00:00 1969
--- rda.snap1/introspect/ChangeLog Tue Nov 19 17:02:03 2002
***************
*** 0 ****
--- 1,14 ----
+ 2002-11-19 Michael Snyder <msnyder@redhat.com>
+
+ New directory "introspect" for introspect target tracing.
+ * trace-dummy.c: New file. Stubs for targets that
+ do not implement introspect trace.
+ * configure.in: New file, autoconf source.
+ * config.in: New file. Not generated by autoheader.
+ * aclocal.m4: New file. Not generated by aclocal.
+ * Makefile.am: New file, automake source.
+ * Makefile.in: New file, generated by automake.
+ * configure: New file, generated by autoconf.
+
+
+
diff -rpN rda/introspect/Makefile.am rda.snap1/introspect/Makefile.am
*** rda/introspect/Makefile.am Wed Dec 31 16:00:00 1969
--- rda.snap1/introspect/Makefile.am Wed Nov 20 11:56:28 2002
***************
*** 0 ****
--- 1,14 ----
+ ## Process this with automake to create Makefile.in
+
+ AUTOMAKE_OPTIONS = foreign
+
+ # Create a libtool convenience archive
+ # ... and a plain library archive for non-libtool clients
+ noinst_LTLIBRARIES = libtrace_d.la
+ noinst_LIBRARIES = libtrace_d.a
+
+ INCLUDES = -I$(srcdir) -I$(srcdir)/../include
+
+ trace_SOURCES = trace-dummy.c
+ libtrace_d_la_SOURCES =$(trace_SOURCES)
+ libtrace_d_a_SOURCES =$(trace_SOURCES)
diff -rpN rda/introspect/configure.in rda.snap1/introspect/configure.in
*** rda/introspect/configure.in Wed Dec 31 16:00:00 1969
--- rda.snap1/introspect/configure.in Tue Nov 19 17:11:27 2002
***************
*** 0 ****
--- 1,17 ----
+ dnl Process this file with autoconf to produce a configure script.
+ AC_INIT(trace-dummy.c)
+ AC_CANONICAL_SYSTEM
+ AM_INIT_AUTOMAKE(rda,0.1)
+ AM_CONFIG_HEADER(config.h:config.in)
+
+ dnl automake support
+ AM_MAINTAINER_MODE
+ AM_PROG_LIBTOOL
+ AC_EXEEXT
+ AC_LANG_C
+
+ dnl headers
+ AC_CHECK_HEADERS(errno.h)
+
+ dnl Outputs
+ AC_OUTPUT(Makefile)
diff -rpN rda/introspect/trace-dummy.c rda.snap1/introspect/trace-dummy.c
*** rda/introspect/trace-dummy.c Wed Dec 31 16:00:00 1969
--- rda.snap1/introspect/trace-dummy.c Wed Nov 20 17:07:47 2002
***************
*** 0 ****
--- 1,92 ----
+ /* trace-dummy.c
+
+ Copyright 2002 Red Hat, Inc.
+
+ This file is part of RDA, the Red Hat Debug Agent (and library).
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Alternative licenses for RDA may be arranged by contacting Red Hat,
+ Inc. */
+
+ /*
+ * Provide dummy stub functions for
+ * instances of RDA that do not implement introspect trace agent.
+ */
+
+ #include "gdbserv.h"
+ #include "gdbtrace.h"
+
+ extern void
+ gdbtrace_status_query (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtrace_limit_query (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtrace_buffer_query (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtrace_init (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtrace_start (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtrace_stop (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtracepoint_define (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtrace_frame_select (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtrace_limit_set (struct gdbserv *not_used)
+ {
+ return;
+ }
+
+ extern void
+ gdbtrace_buffer_set (struct gdbserv *not_used)
+ {
+ return;
+ }
+
diff -rpN rda/lib/gdbserv-state.c rda.snap1/lib/gdbserv-state.c
*** rda/lib/gdbserv-state.c Tue Aug 27 18:22:28 2002
--- rda.snap1/lib/gdbserv-state.c Wed Nov 20 17:07:08 2002
***************
*** 32,37 ****
--- 32,38 ----
#include "gdbserv-utils.h"
#include "gdblog.h"
#include "gdbserv-log.h"
+ #include "gdbtrace.h"

static int output_thread_reg (struct gdbserv *gdbserv,
struct gdbserv_thread *thread,
*************** gdbserv_data_packet (struct gdbserv *gdb
*** 685,690 ****
--- 686,692 ----
gdbserv->target->process_rcmd (gdbserv, cmd, sizeof_cmd);
}
}
+ /* FIXME: add CRC: */
else if (gdbserv_input_string_match (gdbserv, "C") >= 0)
{
do_current_thread_query (gdbserv);
*************** gdbserv_data_packet (struct gdbserv *gdb
*** 701,706 ****
--- 703,720 ----
{
do_thread_extra_info_query (gdbserv);
}
+ else if (gdbserv_input_string_match (gdbserv, "TStatus") >= 0)
+ {
+ gdbtrace_status_query (gdbserv);
+ }
+ else if (gdbserv_input_string_match (gdbserv, "TLimit:") >= 0)
+ {
+ gdbtrace_limit_query (gdbserv);
+ }
+ else if (gdbserv_input_string_match (gdbserv, "TBuffer:") >= 0)
+ {
+ gdbtrace_buffer_query (gdbserv);
+ }
else if (gdbserv->target->process_get_gen)
{
gdbserv->target->process_get_gen (gdbserv);
*************** gdbserv_data_packet (struct gdbserv *gdb
*** 713,719 ****
break;

case 'Q': /* general set packet */
! if (gdbserv->target->process_set_gen)
gdbserv->target->process_set_gen (gdbserv);
else
{
--- 727,761 ----
break;

case 'Q': /* general set packet */
! if (gdbserv_input_string_match (gdbserv, "Tinit") >= 0)
! {
! gdbtrace_init (gdbserv);
! }
! else if (gdbserv_input_string_match (gdbserv, "TStart") >= 0)
! {
! gdbtrace_start (gdbserv);
! }
! else if (gdbserv_input_string_match (gdbserv, "Tstop") >= 0)
! {
! gdbtrace_stop (gdbserv);
! }
! else if (gdbserv_input_string_match (gdbserv, "TDP:") >= 0)
! {
! do_tracepoint_define (gdbserv);
! }
! else if (gdbserv_input_string_match (gdbserv, "TFrame:") >= 0)
! {
! gdbtrace_frame_select (gdbserv);
! }
! else if (gdbserv_input_string_match (gdbserv, "TLimit:") >= 0)
! {
! gdbtrace_limit_set (gdbserv);
! }
! else if (gdbserv_input_string_match (gdbserv, "TBuffer:") >= 0)
! {
! gdbtrace_buffer_set (gdbserv);
! }
! else if (gdbserv->target->process_set_gen)
gdbserv->target->process_set_gen (gdbserv);
else
{
diff -rpN rda/samples/Makefile.am rda.snap1/samples/Makefile.am
*** rda/samples/Makefile.am Tue Aug 27 18:22:28 2002
--- rda.snap1/samples/Makefile.am Wed Nov 20 12:27:33 2002
*************** INCLUDES = -I$(srcdir) -I$(srcdir)/../in
*** 12,25 ****

sample_SOURCES = main.c demo-target.c
sample_DEPLIBS = ../lib/librda.la
! sample_LDADD = $(sample_DEPLIBS) $(INTLLIBS)
sample_DEPENDENCIES = $(sample_DEPLIBS) $(INTLDEPS)

async_SOURCES = async.c demo-target.c
! async_LDADD = ../lib/librda.la

poll_SOURCES = poll.c demo-target.c
! poll_LDADD = ../lib/librda.la

thread_SOURCES = thread.c demo-target.c
! thread_LDADD = ../lib/librda.la
--- 12,25 ----

sample_SOURCES = main.c demo-target.c
sample_DEPLIBS = ../lib/librda.la
! sample_LDADD = $(sample_DEPLIBS) $(INTLLIBS) ../introspect/libtrace_d.la
sample_DEPENDENCIES = $(sample_DEPLIBS) $(INTLDEPS)

async_SOURCES = async.c demo-target.c
! async_LDADD = ../lib/librda.la ../introspect/libtrace_d.la

poll_SOURCES = poll.c demo-target.c
! poll_LDADD = ../lib/librda.la ../introspect/libtrace_d.la

thread_SOURCES = thread.c demo-target.c
! thread_LDADD = ../lib/librda.la ../introspect/libtrace_d.la
diff -rpN rda/samples/Makefile.in rda.snap1/samples/Makefile.in
*** rda/samples/Makefile.in Mon Nov 4 10:48:57 2002
--- rda.snap1/samples/Makefile.in Wed Nov 20 12:27:24 2002
*************** INCLUDES = -I$(srcdir) -I$(srcdir)/../in
*** 124,140 ****

sample_SOURCES = main.c demo-target.c
sample_DEPLIBS = ../lib/librda.la
! sample_LDADD = $(sample_DEPLIBS) $(INTLLIBS)
sample_DEPENDENCIES = $(sample_DEPLIBS) $(INTLDEPS)

async_SOURCES = async.c demo-target.c
! async_LDADD = ../lib/librda.la

poll_SOURCES = poll.c demo-target.c
! poll_LDADD = ../lib/librda.la

thread_SOURCES = thread.c demo-target.c
! thread_LDADD = ../lib/librda.la
subdir = samples
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
--- 124,140 ----

sample_SOURCES = main.c demo-target.c
sample_DEPLIBS = ../lib/librda.la
! sample_LDADD = $(sample_DEPLIBS) $(INTLLIBS) ../introspect/libtrace_d.la
sample_DEPENDENCIES = $(sample_DEPLIBS) $(INTLDEPS)

async_SOURCES = async.c demo-target.c
! async_LDADD = ../lib/librda.la ../introspect/libtrace_d.la

poll_SOURCES = poll.c demo-target.c
! poll_LDADD = ../lib/librda.la ../introspect/libtrace_d.la

thread_SOURCES = thread.c demo-target.c
! thread_LDADD = ../lib/librda.la ../introspect/libtrace_d.la
subdir = samples
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
diff -rpN rda/unix/Makefile.am rda.snap1/unix/Makefile.am
*** rda/unix/Makefile.am Tue Aug 27 18:22:28 2002
--- rda.snap1/unix/Makefile.am Wed Nov 20 12:19:07 2002
*************** rda_SOURCES = server.c
*** 10,15 ****
EXTRA_rda_SOURCES = linux-target.c solaris-target.c \
ptrace-target.c dummy-target.c
TARGET_MODULES = @TARGET_MODULES@
! rda_LDADD = $(TARGET_MODULES) ../lib/librda.la
rda_DEPENDENCIES = $(server_OBJECTS) $(TARGET_MODULES)
rda_LDFLAGS = -ldl -rdynamic
--- 10,15 ----
EXTRA_rda_SOURCES = linux-target.c solaris-target.c \
ptrace-target.c dummy-target.c
TARGET_MODULES = @TARGET_MODULES@
! rda_LDADD = $(TARGET_MODULES) ../lib/librda.la ../introspect/libtrace_d.la
rda_DEPENDENCIES = $(server_OBJECTS) $(TARGET_MODULES)
rda_LDFLAGS = -ldl -rdynamic
diff -rpN rda/unix/Makefile.in rda.snap1/unix/Makefile.in
*** rda/unix/Makefile.in Tue Aug 27 18:22:28 2002
--- rda.snap1/unix/Makefile.in Wed Nov 20 12:19:03 2002
*************** EXTRA_rda_SOURCES = linux-target.c solar
*** 87,93 ****
ptrace-target.c dummy-target.c

TARGET_MODULES = @TARGET_MODULES@
! rda_LDADD = $(TARGET_MODULES) ../lib/librda.la
rda_DEPENDENCIES = $(server_OBJECTS) $(TARGET_MODULES)
rda_LDFLAGS = -ldl -rdynamic
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
--- 87,93 ----
ptrace-target.c dummy-target.c

TARGET_MODULES = @TARGET_MODULES@
! rda_LDADD = $(TARGET_MODULES) ../lib/librda.la ../introspect/libtrace_d.la
rda_DEPENDENCIES = $(server_OBJECTS) $(TARGET_MODULES)
rda_LDFLAGS = -ldl -rdynamic
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4