From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27137 invoked by alias); 23 Jan 2012 14:03:35 -0000 Received: (qmail 27129 invoked by uid 22791); 23 Jan 2012 14:03:33 -0000 X-SWARE-Spam-Status: No, hits=0.9 required=5.0 tests=AWL,BAYES_50,FROM_12LTRDOM X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 14:03:20 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1RpKUS-0006kf-54 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Mon, 23 Jan 2012 06:03:20 -0800 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 23 Jan 2012 06:03:20 -0800 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Mon, 23 Jan 2012 06:03:18 -0800 Message-ID: <4F1D68A2.2080503@codesourcery.com> Date: Mon, 23 Jan 2012 14:07:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: Subject: [patch 6/8] Agent's capability References: <4F1D55D7.7030506@codesourcery.com> In-Reply-To: <4F1D55D7.7030506@codesourcery.com> Content-Type: multipart/mixed; boundary="------------090709070802080501020903" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00770.txt.bz2 --------------090709070802080501020903 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Content-length: 552 GDB/GDBserver could be able to talk with different agents, if they follow the same protocol. However, different agents may have different capabilities, say, one agent can install fast tracepoint, while the other agent can't. Agent capability is to present what agent can do. In agent side, we use an interger bit map, and each bit represents a corresponding capability. This piece of work is different from this, which is about target capability, http://sourceware.org/gdb/current/onlinedocs/gdb/Varying-Target-Capabilities.html -- Yao (齐尧) --------------090709070802080501020903 Content-Type: text/x-patch; name="0006-agent-capability.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0006-agent-capability.patch" Content-length: 2776 2012-01-23 Yao Qi * common/agent.c (struct ipa_sym_addresses) : New. (agent_check_capability): New. (symbol_list): New array element. * common/agent.h (enum agent_capa): New. --- gdb/common/agent.c | 31 +++++++++++++++++++++++++++++++ gdb/common/agent.h | 15 +++++++++++++++ 2 files changed, 46 insertions(+), 0 deletions(-) diff --git a/gdb/common/agent.c b/gdb/common/agent.c index 5c66071..f4ff08c 100644 --- a/gdb/common/agent.c +++ b/gdb/common/agent.c @@ -44,6 +44,7 @@ struct ipa_sym_addresses { CORE_ADDR addr_helper_thread_id; CORE_ADDR addr_cmd_buf; + CORE_ADDR addr_capability; }; /* Cache of the helper thread id. */ @@ -57,6 +58,7 @@ static struct } symbol_list[] = { IPA_SYM(helper_thread_id), IPA_SYM(cmd_buf), + IPA_SYM(capability), }; static struct ipa_sym_addresses ipa_sym_addrs; @@ -114,6 +116,9 @@ agent_get_helper_thread_id (void) return helper_thread_id; } +/* Each bit of it stands for a capability of agent. */ +static unsigned int agent_capability = 0; + /* Connects to synchronization socket. PID is the pid of inferior, which is used to set up connection socket. */ @@ -260,3 +265,29 @@ agent_run_command (int pid, const char *cmd, int len) } } } + +/* Return true if agent has capability AGENT_CAP, otherwise return false. */ + +int +agent_check_capability (enum agent_capa agent_capa) +{ + if (agent_capability == 0) + { +#ifdef GDBSERVER + if (read_inferior_memory (ipa_sym_addrs.addr_capability, + (unsigned char *) &agent_capability, + sizeof agent_capability)) +#else + enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch); + gdb_byte buf[4]; + + if (target_read_memory (ipa_sym_addrs.addr_capability, + buf, sizeof buf) == 0) + agent_capability = extract_unsigned_integer (buf, sizeof buf, + byte_order); + else +#endif + warning ("Error reading helper thread's id in lib"); + } + return agent_capability & agent_capa; +} diff --git a/gdb/common/agent.h b/gdb/common/agent.h index 079b65e..cf3fab1 100644 --- a/gdb/common/agent.h +++ b/gdb/common/agent.h @@ -36,3 +36,18 @@ void agent_look_up_symbols (void); extern int debug_agent ; extern int use_agent; + +/* Capability of agent. Different agents may have different capabilities, + such as installing fast tracepoint or evaluating breakpoint conditions. + Capabilities are represented by bit-maps, and each capability occupy one + bit. */ + +enum agent_capa +{ + /* Capability to install fast tracepoint. */ + AGENT_CAPA_FAST_TRACE = 0x1, + /* Capability to install static tracepoint. */ + AGENT_CAPA_STATIC_TRACE = (0x1 << 1), +}; + +int agent_check_capability (enum agent_capa); -- 1.7.0.4 --------------090709070802080501020903--