From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21323 invoked by alias); 9 Nov 2009 20:02:45 -0000 Received: (qmail 21138 invoked by uid 22791); 9 Nov 2009 20:02:45 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from fg-out-1718.google.com (HELO fg-out-1718.google.com) (72.14.220.155) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 09 Nov 2009 20:02:39 +0000 Received: by fg-out-1718.google.com with SMTP id e21so809034fga.12 for ; Mon, 09 Nov 2009 12:02:36 -0800 (PST) Received: by 10.103.48.20 with SMTP id a20mr3197193muk.121.1257796956543; Mon, 09 Nov 2009 12:02:36 -0800 (PST) Received: from ?128.12.239.131? (tsukiakari.Stanford.EDU [128.12.239.131]) by mx.google.com with ESMTPS id y37sm38141mug.34.2009.11.09.12.02.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 09 Nov 2009 12:02:35 -0800 (PST) Message-ID: <4AF87557.8020701@stanford.edu> Date: Mon, 09 Nov 2009 20:22:00 -0000 From: Arjun Roy User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Thunderbird/3.0b4 MIME-Version: 1.0 To: tromey@redhat.com CC: gdb@sourceware.org Subject: Re: Python Scripting Question References: <4AF63479.7010602@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2009-11/txt/msg00100.txt.bz2 On 11/09/2009 08:25 AM, Tom Tromey wrote: > Arjun> Traceback (most recent call last): > Arjun> File "", line 2, in > Arjun> TypeError: argument 1 must be string without null bytes, not str > Arjun> Error while executing Python code. > > Arjun> Is this a bug, am I misunderstanding the right way to do it, or what? > > It is a bug. > > Arjun> 2. Ideally, I'd like to write a really simple script that: > Arjun> - starts running a program > Arjun> - steps through each instruction one by one, recording the opcode for > Arjun> each instruction performed > Arjun> - and stops when the program is over. > > Arjun> Does gdb-python support that? > > Not yet. Better execution control is on our wish-list. There was a SoC > project to implement some of this; the patches need a bit of reworking > though. > > Tom > It looks as though the two main things this would need would be to: 1. Be able to access the output one gets from executing a GDB command. Ideally one would get an object with various fields filled in based on the type of command, but for my purposes even a string would do - as long as the results can be accessed somehow. 2. Some python objects for representing the current execution state of the program, where one could call methods for determining what's going on. Then in my case, a script would be conceptually as simple as: whileProgramStillRunning() nexti op = getopcode from (disassemble at $pc, $pc+1) // do whatever i want with the result How easy to hack in would this be? -Arjun