Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--agent.vcproj6
-rw-r--r--config.h22
-rw-r--r--framework/channel_tcp.c2
-rw-r--r--framework/context.c2
-rw-r--r--main/main.c2
-rw-r--r--server/Makefile30
-rw-r--r--server/about.html31
-rw-r--r--server/config.h83
-rw-r--r--server/edl-v10.html59
-rw-r--r--server/main/main.c183
-rw-r--r--server/server.sln26
-rw-r--r--server/server.vcproj283
-rw-r--r--server/services/context-proxy.c54
-rw-r--r--services/diagnostics.c19
-rw-r--r--services/processes.c9
-rw-r--r--services/registers.c36
-rw-r--r--services/stacktrace.c21
-rw-r--r--services/tcf_elf.c28
-rw-r--r--system/Darwin/context-darwin.c4
-rw-r--r--system/FreeBSD/context-freebsd.c4
-rw-r--r--system/GNU/Linux/context-linux.c4
-rw-r--r--system/VxWorks/context-vxworks.c4
-rw-r--r--system/Windows/context-win32.c4
-rw-r--r--system/Windows/regset.h2
24 files changed, 830 insertions, 88 deletions
diff --git a/agent.vcproj b/agent.vcproj
index 9fed4486..6e0e80e7 100644
--- a/agent.vcproj
+++ b/agent.vcproj
@@ -19,7 +19,6 @@
OutputDirectory=".\obj\MSVC\Release"
IntermediateDirectory=".\obj\MSVC\Release"
ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
@@ -70,7 +69,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="odbc32.lib odbccp32.lib WS2_32.lib Iphlpapi.lib"
+ AdditionalDependencies="WS2_32.lib Iphlpapi.lib"
OutputFile=".\obj\MSVC\Release/agent.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
@@ -109,7 +108,6 @@
OutputDirectory=".\obj\MSVC\Debug"
IntermediateDirectory=".\obj\MSVC\Debug"
ConfigurationType="1"
- InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
@@ -160,7 +158,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="odbc32.lib odbccp32.lib WS2_32.lib Iphlpapi.lib"
+ AdditionalDependencies="WS2_32.lib Iphlpapi.lib"
OutputFile=".\obj\MSVC\Debug/agent.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
diff --git a/config.h b/config.h
index 1e4896b5..90f84d7f 100644
--- a/config.h
+++ b/config.h
@@ -62,12 +62,15 @@
#if !defined(SERVICE_Memory)
#define SERVICE_Memory (TARGET_UNIX || TARGET_VXWORKS || TARGET_WINDOWS)
#endif
-#if !defined(SERVICE_MemoryMap)
-#define SERVICE_MemoryMap (TARGET_UNIX || TARGET_VXWORKS || TARGET_WINDOWS)
-#endif
#if !defined(SERVICE_Registers)
#define SERVICE_Registers (TARGET_UNIX || TARGET_VXWORKS || TARGET_WINDOWS)
#endif
+#if !defined(SERVICE_Processes)
+#define SERVICE_Processes (TARGET_UNIX || TARGET_VXWORKS || TARGET_WINDOWS)
+#endif
+#if !defined(SERVICE_MemoryMap)
+#define SERVICE_MemoryMap (TARGET_UNIX || TARGET_VXWORKS || TARGET_WINDOWS)
+#endif
#if !defined(SERVICE_StackTrace)
#define SERVICE_StackTrace (TARGET_UNIX || TARGET_VXWORKS || TARGET_WINDOWS)
#endif
@@ -75,10 +78,7 @@
#define SERVICE_Symbols (TARGET_UNIX || TARGET_VXWORKS || TARGET_MSVC)
#endif
#if !defined(SERVICE_LineNumbers)
-#define SERVICE_LineNumbers (TARGET_UNIX || TARGET_MSVC)
-#endif
-#if !defined(SERVICE_Processes)
-#define SERVICE_Processes (TARGET_UNIX || TARGET_VXWORKS || TARGET_WINDOWS)
+#define SERVICE_LineNumbers (TARGET_UNIX || TARGET_VXWORKS || TARGET_MSVC)
#endif
#if !defined(SERVICE_FileSystem)
#define SERVICE_FileSystem (TARGET_UNIX || TARGET_VXWORKS || TARGET_WINDOWS)
@@ -125,8 +125,12 @@
# define ENABLE_Cmdline 1
#endif
+#if !defined(ENABLE_ContextProxy)
+# define ENABLE_ContextProxy 0
+#endif
+
#if !defined(ENABLE_DebugContext)
-# define ENABLE_DebugContext (SERVICE_RunControl || SERVICE_Breakpoints || SERVICE_Memory || SERVICE_Registers || SERVICE_StackTrace)
+# define ENABLE_DebugContext (ENABLE_ContextProxy || SERVICE_RunControl || SERVICE_Breakpoints || SERVICE_Memory || SERVICE_Registers || SERVICE_StackTrace)
#endif
#if !defined(ENABLE_ELF)
@@ -142,7 +146,7 @@
#endif
#if !defined(ENABLE_RCBP_TEST)
-# define ENABLE_RCBP_TEST (SERVICE_RunControl && SERVICE_Breakpoints)
+# define ENABLE_RCBP_TEST (!ENABLE_ContextProxy && (SERVICE_RunControl && SERVICE_Breakpoints))
#endif
#if !defined(ENABLE_AIO)
diff --git a/framework/channel_tcp.c b/framework/channel_tcp.c
index 88a41929..fbe32b51 100644
--- a/framework/channel_tcp.c
+++ b/framework/channel_tcp.c
@@ -75,7 +75,7 @@ struct ChannelTCP {
int read_done;
#if ENABLE_Splice
- int pipefd[2]; /* Pipe used to splice data between a fd and the channel */
+ int pipefd[2]; /* Pipe used to splice data between a fd and the channel */
#endif /* ENABLE_Splice */
/* Input stream buffer */
diff --git a/framework/context.c b/framework/context.c
index 41b4589d..3dd9c7cb 100644
--- a/framework/context.c
+++ b/framework/context.c
@@ -95,7 +95,7 @@ void add_context_event_listener(ContextEventListener * listener, void * client_d
event_listeners = listener;
}
-#ifndef WIN32
+#if !defined(WIN32) && !ENABLE_ContextProxy
#define CASE(var) case var: return ""#var;
char * signal_name(int signal) {
diff --git a/main/main.c b/main/main.c
index c039f638..c99f7149 100644
--- a/main/main.c
+++ b/main/main.c
@@ -116,7 +116,7 @@ int main(int argc, char ** argv) {
break;
case 't':
-#if ENABLE_DebugContext
+#if ENABLE_RCBP_TEST
test_proc();
#endif
exit(0);
diff --git a/server/Makefile b/server/Makefile
new file mode 100644
index 00000000..3247086e
--- /dev/null
+++ b/server/Makefile
@@ -0,0 +1,30 @@
+TCF_AGENT_DIR=../agent
+
+include $(TCF_AGENT_DIR)/Makefile.inc
+
+CFLAGS := $(foreach dir,$(SRCDIRS),-I$(dir)) $(CFLAGS)
+HFILES := $(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.h)) $(HFILES)
+CFILES := $(sort $(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*.c)) $(CFILES))
+
+EXECS = $(BINDIR)/server$(EXTEXE)
+
+all: $(EXECS)
+
+$(BINDIR)/libtcf$(EXTLIB) : $(OFILES)
+ $(AR) -rc $@ $^
+ $(RANLIB)
+
+$(BINDIR)/server$(EXTEXE): $(BINDIR)/main/main$(EXTOBJ) $(BINDIR)/libtcf$(EXTLIB)
+ $(CC) $(CFLAGS) -o $@ $(BINDIR)/main/main$(EXTOBJ) $(BINDIR)/libtcf$(EXTLIB) $(LIBS)
+
+$(BINDIR)/%$(EXTOBJ): %.c $(HFILES) Makefile
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+$(BINDIR)/%$(EXTOBJ): $(TCF_AGENT_DIR)/%.c $(HFILES) Makefile
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+clean:
+ rm -rf $(BINDIR)
+
diff --git a/server/about.html b/server/about.html
new file mode 100644
index 00000000..26aa2655
--- /dev/null
+++ b/server/about.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>July 28, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;), and the Eclipse Distribution License
+Version 1.0 (&quot;EDL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+A copy of the EDL is available
+at <a href="http://www.eclipse.org/org/documents/edl-v10.php">http://www.eclipse.org/org/documents/edl-v10.php</a>.
+For purposes of the EPL and the EDL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL and EDL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/server/config.h b/server/config.h
new file mode 100644
index 00000000..6bd046c6
--- /dev/null
+++ b/server/config.h
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+#ifndef D_config
+#define D_config
+
+#include "mdep.h"
+
+#if !defined(SERVICE_Locator)
+#define SERVICE_Locator 1
+#endif
+
+#if !defined(ENABLE_ZeroCopy)
+#define ENABLE_ZeroCopy 1
+#endif
+
+#if !defined(ENABLE_Splice)
+# if (ENABLE_ZeroCopy) && defined(SPLICE_F_MOVE)
+# define ENABLE_Splice 1
+# else
+# define ENABLE_Splice 0
+# endif
+#endif
+
+#if !defined(ENABLE_Trace)
+# define ENABLE_Trace 1
+#endif
+
+#if !defined(ENABLE_Discovery)
+# define ENABLE_Discovery 1
+#endif
+
+#if !defined(ENABLE_ContextProxy)
+# define ENABLE_ContextProxy 1
+#endif
+
+#if !defined(ENABLE_DebugContext)
+# define ENABLE_DebugContext 1
+#endif
+
+#if !defined(ENABLE_ELF)
+# define ENABLE_ELF 1
+#endif
+
+#if !defined(ENABLE_SSL)
+# if (TARGET_UNIX) && !defined(__APPLE__)
+# define ENABLE_SSL 1
+# else
+# define ENABLE_SSL 0
+# endif
+#endif
+
+#ifdef CONFIG_MAIN
+/*
+ * This part of config.h contains services initialization code,
+ * which is executed during agent startup.
+ */
+
+#include "discovery.h"
+#include "diagnostics.h"
+
+static void ini_services(Protocol * proto, TCFBroadcastGroup * bcg, TCFSuspendGroup * spg) {
+#if SERVICE_Locator
+ ini_locator_service(proto, bcg);
+#endif
+
+ ini_diagnostics_service(proto);
+}
+
+#endif /* CONFIG_MAIN */
+
+#endif /* D_config */
diff --git a/server/edl-v10.html b/server/edl-v10.html
new file mode 100644
index 00000000..58cf7c3f
--- /dev/null
+++ b/server/edl-v10.html
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Distribution License - Version 1.0</title>
+<style type="text/css">
+ body {
+ size: 8.5in 11.0in;
+ margin: 0.25in 0.5in 0.25in 0.5in;
+ tab-interval: 0.5in;
+ }
+ p {
+ margin-left: auto;
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ }
+ p.list {
+ margin-left: 0.5in;
+ margin-top: 0.05em;
+ margin-bottom: 0.05em;
+ }
+ </style>
+
+</head>
+
+<body lang="EN-US">
+
+<p><b>Eclipse Distribution License - v 1.0</b></p>
+
+<p>Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. </p>
+
+<p>All rights reserved.</p>
+<p>Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+<ul><li>Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer. </li>
+<li>Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution. </li>
+<li>Neither the name of the Eclipse Foundation, Inc. nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission. </li></ul>
+</p>
+<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.</p>
+
+</body>
+
+</html>
diff --git a/server/main/main.c b/server/main/main.c
new file mode 100644
index 00000000..ba453890
--- /dev/null
+++ b/server/main/main.c
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+/*
+ * TCF Server main module.
+ *
+ * TCF Server is a value-add that provides StackTrace, Symbols, LineNumbers and Expressions services.
+ */
+
+#define CONFIG_MAIN
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
+#include "asyncreq.h"
+#include "events.h"
+#include "trace.h"
+#include "myalloc.h"
+#include "json.h"
+#include "channel.h"
+#include "protocol.h"
+#include "proxy.h"
+#include "discovery.h"
+#include "errors.h"
+
+static char * progname;
+static Protocol * proto;
+static ChannelServer * serv;
+static TCFBroadcastGroup * bcg;
+static TCFSuspendGroup * spg;
+
+static void channel_server_connecting(Channel * c) {
+ trace(LOG_PROTOCOL, "channel server connecting");
+
+ send_hello_message(c->client_data, c);
+ flush_stream(&c->out);
+}
+
+static void channel_server_connected(Channel * c) {
+ int i;
+
+ trace(LOG_PROTOCOL, "channel server connected, peer services:");
+ for (i = 0; i < c->peer_service_cnt; i++) {
+ trace(LOG_PROTOCOL, " %s", c->peer_service_list[i]);
+ }
+}
+
+static void channel_server_receive(Channel * c) {
+ handle_protocol_message(c->client_data, c);
+}
+
+static void channel_server_disconnected(Channel * c) {
+ trace(LOG_PROTOCOL, "channel server disconnected");
+}
+
+static void channel_new_connection(ChannelServer * serv, Channel * c) {
+ protocol_reference(proto);
+ c->client_data = proto;
+ c->connecting = channel_server_connecting;
+ c->connected = channel_server_connected;
+ c->receive = channel_server_receive;
+ c->disconnected = channel_server_disconnected;
+ channel_set_suspend_group(c, spg);
+ channel_set_broadcast_group(c, bcg);
+ channel_start(c);
+}
+
+#if defined(_WRS_KERNEL)
+int tcf_va(void) {
+#else
+int main(int argc, char ** argv) {
+#endif
+ int c;
+ int ind;
+ char * s;
+ char * log_name = 0;
+ char * url = "TCP:";
+ PeerServer * ps;
+
+ ini_mdep();
+ ini_trace();
+ ini_asyncreq();
+ ini_events_queue();
+
+#if defined(_WRS_KERNEL)
+
+ progname = "tcf";
+ open_log_file("-");
+ log_mode = 0;
+
+#else
+
+ progname = argv[0];
+
+ /* Parse arguments */
+ for (ind = 1; ind < argc; ind++) {
+ s = argv[ind];
+ if (*s != '-') {
+ break;
+ }
+ s++;
+ while ((c = *s++) != '\0') {
+ switch (c) {
+ case 'l':
+ case 'L':
+ case 's':
+ if (*s == '\0') {
+ if (++ind >= argc) {
+ fprintf(stderr, "%s: error: no argument given to option '%c'\n", progname, c);
+ exit(1);
+ }
+ s = argv[ind];
+ }
+ switch (c) {
+ case 'l':
+ log_mode = strtol(s, 0, 0);
+ break;
+
+ case 'L':
+ log_name = s;
+ break;
+
+ case 's':
+ url = s;
+ break;
+
+ default:
+ fprintf(stderr, "%s: error: illegal option '%c'\n", progname, c);
+ exit(1);
+ }
+ s = "";
+ break;
+
+ default:
+ fprintf(stderr, "%s: error: illegal option '%c'\n", progname, c);
+ exit(1);
+ }
+ }
+ }
+
+ open_log_file(log_name);
+
+#endif
+
+ bcg = broadcast_group_alloc();
+ spg = suspend_group_alloc();
+ proto = protocol_alloc();
+ ini_services(proto, bcg, spg);
+
+ ps = channel_peer_from_url(url);
+ if (ps == NULL) {
+ fprintf(stderr, "invalid server URL (-s option value): %s\n", url);
+ exit(1);
+ }
+ peer_server_addprop(ps, loc_strdup("Name"), loc_strdup("TCF Proxy"));
+ peer_server_addprop(ps, loc_strdup("Proxy"), loc_strdup(""));
+ serv = channel_server(ps);
+ if (serv == NULL) {
+ fprintf(stderr, "cannot create TCF server\n");
+ exit(1);
+ }
+ serv->new_conn = channel_new_connection;
+
+ discovery_start();
+
+ /* Process events - must run on the initial thread since ptrace()
+ * returns ECHILD otherwise, thinking we are not the owner. */
+ run_event_loop();
+ return 0;
+}
diff --git a/server/server.sln b/server/server.sln
new file mode 100644
index 00000000..29ab0681
--- /dev/null
+++ b/server/server.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "server", "server.vcproj", "{4EBA43E4-98C0-4F00-ADA7-21758F1BAE77}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "agent", "..\agent\agent.vcproj", "{A1341B90-F807-4D1F-A48E-C42BE62D9C57}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4EBA43E4-98C0-4F00-ADA7-21758F1BAE77}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4EBA43E4-98C0-4F00-ADA7-21758F1BAE77}.Debug|Win32.Build.0 = Debug|Win32
+ {4EBA43E4-98C0-4F00-ADA7-21758F1BAE77}.Release|Win32.ActiveCfg = Release|Win32
+ {4EBA43E4-98C0-4F00-ADA7-21758F1BAE77}.Release|Win32.Build.0 = Release|Win32
+ {A1341B90-F807-4D1F-A48E-C42BE62D9C57}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A1341B90-F807-4D1F-A48E-C42BE62D9C57}.Debug|Win32.Build.0 = Debug|Win32
+ {A1341B90-F807-4D1F-A48E-C42BE62D9C57}.Release|Win32.ActiveCfg = Release|Win32
+ {A1341B90-F807-4D1F-A48E-C42BE62D9C57}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/server/server.vcproj b/server/server.vcproj
new file mode 100644
index 00000000..e1e76838
--- /dev/null
+++ b/server/server.vcproj
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="server"
+ ProjectGUID="{4EBA43E4-98C0-4F00-ADA7-21758F1BAE77}"
+ RootNamespace="server"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\obj\MSVC\Debug"
+ IntermediateDirectory=".\obj\MSVC\Debug"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".,services,main,../agent/framework,../agent/services"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="WS2_32.lib Iphlpapi.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\obj\MSVC\Release"
+ IntermediateDirectory=".\obj\MSVC\Release"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=".,services,main,../agent/framework,../agent/services"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="WS2_32.lib Iphlpapi.lib"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="services"
+ >
+ <File
+ RelativePath=".\services\context-proxy.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\services\diagnostics.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\services\discovery.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\services\discovery_udp.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="main"
+ >
+ <File
+ RelativePath=".\main\main.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="framework"
+ >
+ <File
+ RelativePath="..\agent\framework\asyncreq.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\base64.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\channel.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\channel_tcp.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\context.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\errors.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\events.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\exceptions.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\inputbuf.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\ip_ifc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\json.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\mdep.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\myalloc.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\peer.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\protocol.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\proxy.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\streams.c"
+ >
+ </File>
+ <File
+ RelativePath="..\agent\framework\trace.c"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\config.h"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/server/services/context-proxy.c b/server/services/context-proxy.c
new file mode 100644
index 00000000..f57aea74
--- /dev/null
+++ b/server/services/context-proxy.c
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Eclipse Distribution License v1.0 which accompany this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+/*
+ * This module forwards handling of process/thread OS contexts to remote peer.
+ */
+
+#include "config.h"
+
+#if ENABLE_DebugContext && ENABLE_ContextProxy
+
+#include <errno.h>
+#include "context.h"
+
+typedef struct ContextCache ContextCache;
+typedef struct PeerCache PeerCache;
+
+struct ContextCache {
+ Context * ctx;
+};
+
+struct PeerCache {
+ int x;
+};
+
+int context_has_state(Context * ctx) {
+ return 0;
+}
+
+int context_write_mem(Context * ctx, ContextAddress address, void * buf, size_t size) {
+ errno = EINVAL;
+ return -1;
+}
+
+int context_read_mem(Context * ctx, ContextAddress address, void * buf, size_t size) {
+ errno = EINVAL;
+ return -1;
+}
+
+void init_contexts_sys_dep(void) {
+}
+
+#endif /* ENABLE_DebugContext && ENABLE_ContextProxy */
diff --git a/services/diagnostics.c b/services/diagnostics.c
index 1ccbabcc..5526709c 100644
--- a/services/diagnostics.c
+++ b/services/diagnostics.c
@@ -25,12 +25,19 @@
#include "protocol.h"
#include "json.h"
#include "exceptions.h"
-#include "runctrl.h"
-#include "symbols.h"
-#include "stacktrace.h"
-#include "streamsservice.h"
-#include "test.h"
+#include "context.h"
#include "myalloc.h"
+#if SERVICE_Symbols
+# include "symbols.h"
+# include "stacktrace.h"
+#endif
+#if SERVICE_Streams
+# include "streamsservice.h"
+#endif
+#if ENABLE_RCBP_TEST
+# include "test.h"
+# include "runctrl.h"
+#endif
static const char * DIAGNOSTICS = "Diagnostics";
@@ -73,7 +80,7 @@ static void command_get_test_list(char * token, Channel * c) {
write_stringz(&c->out, token);
write_errno(&c->out, 0);
#if ENABLE_RCBP_TEST
- if (context_root.next != NULL) arr = "[\"RCBP1\"]";
+ arr = "[\"RCBP1\"]";
#endif
write_stringz(&c->out, arr);
write_stream(&c->out, MARKER_EOM);
diff --git a/services/processes.c b/services/processes.c
index 8b97642f..14a36b40 100644
--- a/services/processes.c
+++ b/services/processes.c
@@ -214,7 +214,6 @@ static void command_get_context(char * token, Channel * c) {
write_stringz(&c->out, "R");
write_stringz(&c->out, token);
- pid = id2pid(id, &parent);
if (pid != 0 && parent == 0) {
#if defined(WIN32)
#elif defined(_WRS_KERNEL)
@@ -534,15 +533,13 @@ static void command_get_signal_list(char * token, Channel * c) {
static void command_get_signal_mask(char * token, Channel * c) {
int err = 0;
char id[256];
- pid_t pid;
Context * ctx = NULL;
json_read_string(&c->inp, id, sizeof(id));
if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX);
if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);
- pid = id2pid(id, NULL);
- ctx = context_find_from_pid(pid);
+ ctx = id2ctx(id);
if (ctx == NULL) err = ERR_INV_CONTEXT;
write_stringz(&c->out, "R");
@@ -569,7 +566,6 @@ static void command_get_signal_mask(char * token, Channel * c) {
static void command_set_signal_mask(char * token, Channel * c) {
int err = 0;
char id[256];
- pid_t pid;
Context * ctx = NULL;
int dont_stop;
int dont_pass;
@@ -582,8 +578,7 @@ static void command_set_signal_mask(char * token, Channel * c) {
if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX);
if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);
- pid = id2pid(id, NULL);
- ctx = context_find_from_pid(pid);
+ ctx = id2ctx(id);
if (ctx == NULL) {
err = ERR_INV_CONTEXT;
}
diff --git a/services/registers.c b/services/registers.c
index 28bb6667..5f1f05d0 100644
--- a/services/registers.c
+++ b/services/registers.c
@@ -183,9 +183,7 @@ static void command_get_children(char * token, Channel * c) {
if (get_frame_info(ctx, frame, &frame_info) < 0) err = errno;
}
else {
- pid_t pid, parent;
- pid = id2pid(id, &parent);
- if (pid != 0 && parent != 0) ctx = context_find_from_pid(pid);
+ ctx = id2ctx(id);
frame = STACK_TOP_FRAME;
}
@@ -196,24 +194,22 @@ static void command_get_children(char * token, Channel * c) {
write_stream(&c->out, '[');
if (err == 0 && ctx != NULL && context_has_state(ctx)) {
- if (ctx != NULL) {
- int cnt = 0;
- char t_id[128];
- RegisterDefinition * reg_def;
- strcpy(t_id, thread_id(ctx));
- for (reg_def = get_reg_definitions(); reg_def->name != NULL; reg_def++) {
- if (frame == STACK_TOP_FRAME || read_reg_value(reg_def, frame_info, NULL) == 0) {
- char r_id[128];
- if (cnt > 0) write_stream(&c->out, ',');
- if (frame == STACK_TOP_FRAME) {
- snprintf(r_id, sizeof(r_id), "R%s.%s", reg_def->name, t_id);
- }
- else {
- snprintf(r_id, sizeof(r_id), "R%s@%d.%s", reg_def->name, frame, t_id);
- }
- json_write_string(&c->out, r_id);
- cnt++;
+ int cnt = 0;
+ char t_id[128];
+ RegisterDefinition * reg_def;
+ strcpy(t_id, thread_id(ctx));
+ for (reg_def = get_reg_definitions(); reg_def->name != NULL; reg_def++) {
+ if (frame == STACK_TOP_FRAME || read_reg_value(reg_def, frame_info, NULL) == 0) {
+ char r_id[128];
+ if (cnt > 0) write_stream(&c->out, ',');
+ if (frame == STACK_TOP_FRAME) {
+ snprintf(r_id, sizeof(r_id), "R%s.%s", reg_def->name, t_id);
+ }
+ else {
+ snprintf(r_id, sizeof(r_id), "R%s@%d.%s", reg_def->name, frame, t_id);
}
+ json_write_string(&c->out, r_id);
+ cnt++;
}
}
}
diff --git a/services/stacktrace.c b/services/stacktrace.c
index 1536eafb..3cc789ac 100644
--- a/services/stacktrace.c
+++ b/services/stacktrace.c
@@ -343,7 +343,6 @@ static void command_get_context(char * token, Channel * c) {
static void command_get_children(char * token, Channel * c) {
char id[256];
int err = 0;
- pid_t pid, parent;
Context * ctx = NULL;
StackTrace * s = NULL;
@@ -351,17 +350,15 @@ static void command_get_children(char * token, Channel * c) {
if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX);
if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);
- pid = id2pid(id, &parent);
- if (pid != 0 && parent != 0) {
- ctx = context_find_from_pid(pid);
- if (ctx != NULL) {
- if (!ctx->intercepted) {
- err = ERR_IS_RUNNING;
- }
- else {
- s = create_stack_trace(ctx);
- }
- }
+ ctx = id2ctx(id);
+ if (ctx == NULL || !context_has_state(ctx)) {
+ /* no children */
+ }
+ else if (!ctx->intercepted) {
+ err = ERR_IS_RUNNING;
+ }
+ else {
+ s = create_stack_trace(ctx);
}
write_stringz(&c->out, "R");
diff --git a/services/tcf_elf.c b/services/tcf_elf.c
index 387ff762..5cf2ae73 100644
--- a/services/tcf_elf.c
+++ b/services/tcf_elf.c
@@ -54,6 +54,8 @@ static Context * elf_list_ctx;
static int elf_list_pos;
static ContextAddress elf_list_addr0;
static ContextAddress elf_list_addr1;
+static MemoryRegion * elf_list_regions;
+static unsigned elf_list_region_cnt;
static void elf_dispose(ELF_File * file) {
@@ -461,15 +463,13 @@ static ELF_File * open_memory_region_file(MemoryRegion * r) {
ELF_File * elf_list_first(Context * ctx, ContextAddress addr0, ContextAddress addr1) {
unsigned i;
- MemoryRegion * regions;
- unsigned region_cnt;
elf_list_ctx = ctx;
elf_list_addr0 = addr0;
elf_list_addr1 = addr1;
- memory_map_get_regions(ctx, &regions, &region_cnt);
- for (i = 0; i < region_cnt; i++) {
- MemoryRegion * r = regions + i;
+ memory_map_get_regions(ctx, &elf_list_regions, &elf_list_region_cnt);
+ for (i = 0; i < elf_list_region_cnt; i++) {
+ MemoryRegion * r = elf_list_regions + i;
if (r->addr <= addr1 && r->addr + r->size >= addr0) {
assert(r->file == NULL);
if (r->ino != 0) {
@@ -489,13 +489,10 @@ ELF_File * elf_list_first(Context * ctx, ContextAddress addr0, ContextAddress ad
ELF_File * elf_list_next(Context * ctx) {
unsigned i;
- MemoryRegion * regions;
- unsigned region_cnt;
assert(ctx == elf_list_ctx);
- memory_map_get_regions(ctx, &regions, &region_cnt);
- for (i = elf_list_pos; i < region_cnt; i++) {
- MemoryRegion * r = regions + i;
+ for (i = elf_list_pos; i < elf_list_region_cnt; i++) {
+ MemoryRegion * r = elf_list_regions + i;
if (r->addr <= elf_list_addr1 && r->addr + r->size >= elf_list_addr0) {
assert(r->file == NULL);
if (r->ino != 0) {
@@ -514,14 +511,10 @@ ELF_File * elf_list_next(Context * ctx) {
void elf_list_done(Context * ctx) {
unsigned i;
- MemoryRegion * regions;
- unsigned region_cnt;
assert(ctx == elf_list_ctx);
- elf_list_ctx = NULL;
- memory_map_get_regions(ctx, &regions, &region_cnt);
- for (i = 0; i < region_cnt; i++) {
- MemoryRegion * r = regions + i;
+ for (i = 0; i < elf_list_region_cnt; i++) {
+ MemoryRegion * r = elf_list_regions + i;
ELF_File * file = (ELF_File *)r->file;
if (file != NULL) {
file->listed = 0;
@@ -529,6 +522,9 @@ void elf_list_done(Context * ctx) {
r->file = NULL;
}
}
+ elf_list_ctx = NULL;
+ elf_list_regions = NULL;
+ elf_list_region_cnt = 0;
}
void elf_add_close_listener(ELFCloseListener listener) {
diff --git a/system/Darwin/context-darwin.c b/system/Darwin/context-darwin.c
index 04f0d368..b99e8f91 100644
--- a/system/Darwin/context-darwin.c
+++ b/system/Darwin/context-darwin.c
@@ -20,6 +20,8 @@
#if defined(__APPLE__)
+#if ENABLE_DebugContext && !ENABLE_ContextProxy
+
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
@@ -37,8 +39,6 @@
#include "breakpoints.h"
#include "waitpid.h"
-#if ENABLE_DebugContext
-
#define WORD_SIZE 4
static LINK pending_list;
diff --git a/system/FreeBSD/context-freebsd.c b/system/FreeBSD/context-freebsd.c
index 637dd461..11ea7cab 100644
--- a/system/FreeBSD/context-freebsd.c
+++ b/system/FreeBSD/context-freebsd.c
@@ -20,6 +20,8 @@
#if defined(__FreeBSD__)
+#if ENABLE_DebugContext && !ENABLE_ContextProxy
+
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
@@ -35,8 +37,6 @@
#include "breakpoints.h"
#include "waitpid.h"
-#if ENABLE_DebugContext
-
#define PTRACE_TRACEME PT_TRACE_ME
#define PTRACE_ATTACH PT_ATTACH
#define PTRACE_GETREGS PT_GETREGS
diff --git a/system/GNU/Linux/context-linux.c b/system/GNU/Linux/context-linux.c
index 92af9a37..4775bf5b 100644
--- a/system/GNU/Linux/context-linux.c
+++ b/system/GNU/Linux/context-linux.c
@@ -20,6 +20,8 @@
#if defined(__linux__)
+#if ENABLE_DebugContext && !ENABLE_ContextProxy
+
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
@@ -39,8 +41,6 @@
#include "waitpid.h"
#include "tcf_elf.h"
-#if ENABLE_DebugContext
-
#if !defined(PTRACE_SETOPTIONS)
#define PTRACE_SETOPTIONS 0x4200
#define PTRACE_GETEVENTMSG 0x4201
diff --git a/system/VxWorks/context-vxworks.c b/system/VxWorks/context-vxworks.c
index 870d5b23..24acbe47 100644
--- a/system/VxWorks/context-vxworks.c
+++ b/system/VxWorks/context-vxworks.c
@@ -20,6 +20,8 @@
#if defined(_WRS_KERNEL)
+#if ENABLE_DebugContext && !ENABLE_ContextProxy
+
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
@@ -32,8 +34,6 @@
#include "breakpoints.h"
#include "waitpid.h"
-#if ENABLE_DebugContext
-
/* TODO: VxWorks RTP support */
#include <taskHookLib.h>
diff --git a/system/Windows/context-win32.c b/system/Windows/context-win32.c
index 815a17c9..6c15e177 100644
--- a/system/Windows/context-win32.c
+++ b/system/Windows/context-win32.c
@@ -20,6 +20,8 @@
#if defined(WIN32)
+#if ENABLE_DebugContext && !ENABLE_ContextProxy
+
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
@@ -91,8 +93,6 @@ unsigned signal_code(int signal) {
return 0;
}
-#if ENABLE_DebugContext
-
typedef struct DebugThreadArgs {
int error;
DWORD context_id;
diff --git a/system/Windows/regset.h b/system/Windows/regset.h
index bb36c407..c0872192 100644
--- a/system/Windows/regset.h
+++ b/system/Windows/regset.h
@@ -19,4 +19,4 @@
#if defined(WIN32)
typedef CONTEXT REG_SET;
-#endif \ No newline at end of file
+#endif

Back to the top