From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 88061 invoked by alias); 24 Nov 2015 13:38:22 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 88049 invoked by uid 89); 24 Nov 2015 13:38:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_40,KAM_LAZY_DOMAIN_SECURITY,LOTS_OF_MONEY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: phoenix.clifford.at Received: from phoenix.clifford.at (HELO phoenix.clifford.at) (88.198.7.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 24 Nov 2015 13:38:20 +0000 Received: by phoenix.clifford.at (Postfix, from userid 1000) id 0354D3380C84; Tue, 24 Nov 2015 14:38:17 +0100 (CET) Date: Tue, 24 Nov 2015 13:38:00 -0000 From: Clifford Wolf To: gdb@sourceware.org Subject: Commands for a minimal GDB stub? Message-ID: <20151124133817.GA10033@clifford.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-11/txt/msg00037.txt.bz2 Hi, I'm trying to write a minimal GDB stub. The documentation states that it is sufficient to implement the g, G, m, M, c, and s commands and that $#00 should be returned for any command not supported by the stub: https://sourceware.org/gdb/onlinedocs/gdb/Overview.html I've now started by implementing a minimal stub that just returns $#00 to everything. This is the conversation my stub is having with gdb (not showing the '+' acknowledgments, '->' for packets from gdb and '<-' for packets from my stub): -> $qSupported:multiprocess+;xmlRegisters=i386;qRelocInsn+#b5 <- $#00 -> $Hg0#df <- $#00 -> $qTStatus#49 <- $#00 -> $?#3f <- $#00 -> $Hc-1#09 <- $#00 -> $qC#b4 <- $#00 -> $qAttached#8f <- $#00 On the GDB console I see the following (it just hangs after the "Invalid remote reply:"): (gdb) target remote :1234 Remote debugging using :1234 warning: Invalid remote reply: Note that none of the commands gdb sent is g, G, m, M, c, or s. So sending those empty replies should be fine, according to the documentation! And here is the same conversation between gdb and my stub, as recorded by wireshark: 00000000 2b + 00000001 24 71 53 75 70 70 6f 72 74 65 64 3a 6d 75 6c 74 $qSupported:mult 00000011 69 70 72 6f 63 65 73 73 2b 3b 78 6d 6c 52 65 67 iprocess+;xmlReg 00000021 69 73 74 65 72 73 3d 69 33 38 36 3b 71 52 65 6c isters=i386;qRel 00000031 6f 63 49 6e 73 6e 2b 23 62 35 ocInsn+#b5 00000000 2b + 00000001 24 $ 00000002 23 # 00000003 30 0 00000004 30 0 0000003B 2b + 0000003C 24 48 67 30 23 64 66 $Hg0#df 00000005 2b + 00000006 24 23 30 30 $#00 00000043 2b + 00000044 24 71 54 53 74 61 74 75 73 23 34 39 $qTStatus#49 0000000A 2b + 0000000B 24 23 30 30 $#00 00000050 2b + 00000051 24 3f 23 33 66 $?#3f 0000000F 2b + 00000010 24 23 30 30 $#00 00000056 2b + 00000057 24 48 63 2d 31 23 30 39 $Hc-1#09 00000014 2b + 00000015 24 23 30 30 $#00 0000005F 2b + 00000060 24 71 43 23 62 34 $qC#b4 00000019 2b + 0000001A 24 23 30 30 $#00 00000066 2b + 00000067 24 71 41 74 74 61 63 68 65 64 23 38 66 $qAttached#8f 0000001E 2b + 0000001F 24 23 30 30 $#00 00000074 2b + I did compare that to what I record when gdb is talking to gdbserver, and the general syntax seems to be the same, meaning I don't think I have screwed up implementing the low-level protocol.. Is the documentation correct and I only need to implement g, G, m, M, c, and s? If so: What did I do wrong? Your help is very appreciated! thanks, - clifford