From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3478 invoked by alias); 30 Apr 2013 23:05:04 -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 3465 invoked by uid 89); 30 Apr 2013 23:05:03 -0000 X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,LOTS_OF_MONEY,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE,SPF_PASS,TW_XF autolearn=no version=3.3.1 Received: from bay0-omc1-s11.bay0.hotmail.com (HELO bay0-omc1-s11.bay0.hotmail.com) (65.54.190.22) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 30 Apr 2013 23:05:02 +0000 Received: from BAY171-W10 ([65.54.190.59]) by bay0-omc1-s11.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 30 Apr 2013 16:05:01 -0700 X-EIP: [pPIc1HJ5FU4Y//kYhclzGVREBcwd5QDO] Message-ID: From: Rouslan Korneychuk To: "gdb@sourceware.org" Subject: A little help with JIT support Date: Tue, 30 Apr 2013 23:05:00 -0000 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2013-04/txt/msg00107.txt.bz2 I wanted to use GDB's JIT support feature in a JIT compiler I'm working on.= This requires creating an object file, so I read the ELF and DWARF 4 speci= fications, and implemented the JIT data structures from the GDB manual. It = all seems to be working except for one thing. The addresses used in the obj= ect file are supposed to be position independent "virtual" addresses, meani= ng they don't represent the final positions in memory. So my first function= is at "address" 0, but GDB is treating these as absolute addresses. For ex= ample: if I try to use the "disassemble" command on my function, it tries t= o read from address 0 (which of course causes an error). Are the addresses in an in-memory object file supposed to be absolute addre= sses? I figure I'm just missing something. Although using absolute addresse= s would work either way, I would prefer to know the proper way, so I would = know how to create executable and dynamic library files. I looked at the in= formation that GCC generates for object files, but it generates too much in= formation for me to guess what mine is missing. I'm using GDB 7.3.1 Here is an example of what I get when I run "readelf -hS" on my object file: ELF Header: =A0 Magic:=A0=A0 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00=20 =A0 Class:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 ELF64 =A0 Data:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 2's complement, little endian =A0 Version:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 1 (current) =A0 OS/ABI:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 UNIX - System V =A0 ABI Version:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 0 =A0 Type:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 REL (Relocatable file) =A0 Machine:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 Advanced Micro Devices X86-64 =A0 Version:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 0x1 =A0 Entry point address:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 0x0 =A0 Start of program headers:=A0=A0=A0=A0=A0=A0=A0=A0=A0 0 (bytes into file) =A0 Start of section headers:=A0=A0=A0=A0=A0=A0=A0=A0=A0 4464 (bytes into f= ile) =A0 Flags:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 0x0 =A0 Size of this header:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 64 (byte= s) =A0 Size of program headers:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 0 (bytes) =A0 Number of program headers:=A0=A0=A0=A0=A0=A0=A0=A0 0 =A0 Size of section headers:=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 64 (bytes) =A0 Number of section headers:=A0=A0=A0=A0=A0=A0=A0=A0 8 =A0 Section header string table index: 7 Section Headers: =A0 [Nr] Name=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Type=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 Address=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Offset =A0=A0=A0=A0=A0=A0 Size=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 EntSize=A0= =A0=A0=A0=A0=A0=A0=A0=A0 Flags=A0 Link=A0 Info=A0 Align =A0 [ 0]=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 NULL=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 0000000000000000=A0 00000000 =A0=A0=A0=A0=A0=A0 0000000000000000=A0 0000000000000000=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 0=A0=A0=A0=A0 0=A0=A0=A0=A0 0 =A0 [ 1] .text=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 PROGBITS=A0=A0=A0=A0=A0= =A0=A0=A0 0000000000000000=A0 00000050 =A0=A0=A0=A0=A0=A0 0000000000000fe0=A0 0000000000000000=A0 AX=A0=A0=A0=A0= =A0=A0 0=A0=A0=A0=A0 0=A0=A0=A0=A0 16 =A0 [ 2] .symtab=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 SYMTAB=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 0000000000000000=A0 00001030 =A0=A0=A0=A0=A0=A0 0000000000000060=A0 0000000000000018=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 3=A0=A0=A0=A0 4=A0=A0=A0=A0 0 =A0 [ 3] .strtab=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 STRTAB=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 0000000000000000=A0 00001090 =A0=A0=A0=A0=A0=A0 0000000000000018=A0 0000000000000000=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 0=A0=A0=A0=A0 0=A0=A0=A0=A0 0 =A0 [ 4] .debug_info=A0=A0=A0=A0=A0=A0 PROGBITS=A0=A0=A0=A0=A0=A0=A0=A0 000= 0000000000000=A0 000010a8 =A0=A0=A0=A0=A0=A0 0000000000000054=A0 0000000000000000=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 0=A0=A0=A0=A0 0=A0=A0=A0=A0 0 =A0 [ 5] .debug_abbrev=A0=A0=A0=A0 PROGBITS=A0=A0=A0=A0=A0=A0=A0=A0 0000000= 000000000=A0 000010fc =A0=A0=A0=A0=A0=A0 000000000000001b=A0 0000000000000000=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 0=A0=A0=A0=A0 0=A0=A0=A0=A0 0 =A0 [ 6] .debug_str=A0=A0=A0=A0=A0=A0=A0 PROGBITS=A0=A0=A0=A0=A0=A0=A0=A0 0= 000000000000000=A0 00001117 =A0=A0=A0=A0=A0=A0 0000000000000011=A0 0000000000000000=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 0=A0=A0=A0=A0 0=A0=A0=A0=A0 0 =A0 [ 7] .shstrtab=A0=A0=A0=A0=A0=A0=A0=A0 STRTAB=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 0000000000000000=A0 00001128 =A0=A0=A0=A0=A0=A0 0000000000000046=A0 0000000000000000=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0 0=A0=A0=A0=A0 0=A0=A0=A0=A0 0 Key to Flags: =A0 W (write), A (alloc), X (execute), M (merge), S (strings), l (large) =A0 I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown) =A0 O (extra OS processing required) o (OS specific), p (processor specific) And if I run "objdump -W" file format elf64-x86-64 Contents of the .debug_info section: =A0 Compilation Unit @ offset 0x0: =A0=A0 Length:=A0=A0=A0=A0=A0=A0=A0 0x48 (32-bit) =A0=A0 Version:=A0=A0=A0=A0=A0=A0 4 =A0=A0 Abbrev Offset: 0 =A0=A0 Pointer Size:=A0 8 =A0<0><17>: Abbrev Number: 1 (DW_TAG_compile_unit) =A0=A0=A0 <18>=A0=A0 DW_AT_use_UTF8=A0=A0=A0 : 1=A0=A0=A0=20 =A0<1><18>: Abbrev Number: 2 (DW_TAG_subprogram) =A0=A0=A0 <19>=A0=A0 DW_AT_name=A0=A0=A0=A0=A0=A0=A0 : (indirect string, of= fset: 0x0): $module$=A0=A0=A0=20 =A0=A0=A0 <21>=A0=A0 DW_AT_high_pc=A0=A0=A0=A0 : 2051=A0=A0=A0=20 =A0=A0=A0 <23>=A0=A0 DW_AT_low_pc=A0=A0=A0=A0=A0 : 0x0=A0=A0=A0=20 =A0<1><2b>: Abbrev Number: 2 (DW_TAG_subprogram) =A0=A0=A0 <2c>=A0=A0 DW_AT_name=A0=A0=A0=A0=A0=A0=A0 : (indirect string, of= fset: 0x9): gentest=A0=A0=A0=20 =A0=A0=A0 <34>=A0=A0 DW_AT_high_pc=A0=A0=A0=A0 : 1650=A0=A0=A0=20 =A0=A0=A0 <36>=A0=A0 DW_AT_low_pc=A0=A0=A0=A0=A0 : 0x810=A0=A0=A0=20 =A0<1><3e>: Abbrev Number: 3 (DW_TAG_subprogram) =A0=A0=A0 <3f>=A0=A0 DW_AT_high_pc=A0=A0=A0=A0 : 287=A0=A0=A0=20 =A0=A0=A0 <41>=A0=A0 DW_AT_low_pc=A0=A0=A0=A0=A0 : 0xe90=A0=A0=A0=20 =A0<1><49>: Abbrev Number: 3 (DW_TAG_subprogram) =A0=A0=A0 <4a>=A0=A0 DW_AT_high_pc=A0=A0=A0=A0 : 48=A0=A0=A0=20 =A0=A0=A0 <4b>=A0=A0 DW_AT_low_pc=A0=A0=A0=A0=A0 : 0xfb0=A0=A0=A0=20 Contents of the .debug_abbrev section: =A0 Number TAG =A0=A0 1=A0=A0=A0=A0=A0 DW_TAG_compile_unit=A0=A0=A0 [has children] =A0=A0=A0 DW_AT_use_UTF8=A0=A0=A0=A0 DW_FORM_flag_present =A0=A0 2=A0=A0=A0=A0=A0 DW_TAG_subprogram=A0=A0=A0 [no children] =A0=A0=A0 DW_AT_name=A0=A0=A0=A0=A0=A0=A0=A0 DW_FORM_strp =A0=A0=A0 DW_AT_high_pc=A0=A0=A0=A0=A0 DW_FORM_udata =A0=A0=A0 DW_AT_low_pc=A0=A0=A0=A0=A0=A0 DW_FORM_addr =A0=A0 3=A0=A0=A0=A0=A0 DW_TAG_subprogram=A0=A0=A0 [no children] =A0=A0=A0 DW_AT_high_pc=A0=A0=A0=A0=A0 DW_FORM_udata =A0=A0=A0 DW_AT_low_pc=A0=A0=A0=A0=A0=A0 DW_FORM_addr Contents of the .debug_str section: =A0 0x00000000 246d6f64 756c6524 0067656e 74657374 $module$.gentest =A0 0x00000010 00=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 .=20=09=09=20=09=20=20=20=09=09= =20=20 >From gdb-return-42073-listarch-gdb=sources.redhat.com@sourceware.org Wed May 01 00:51:43 2013 Return-Path: Delivered-To: listarch-gdb@sources.redhat.com Received: (qmail 23367 invoked by alias); 1 May 2013 00:51:43 -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 Delivered-To: mailing list gdb@sourceware.org Received: (qmail 23192 invoked by uid 89); 1 May 2013 00:51:42 -0000 X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.1 Received: from mail-ve0-f182.google.com (HELO mail-ve0-f182.google.com) (209.85.128.182) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 01 May 2013 00:51:41 +0000 Received: by mail-ve0-f182.google.com with SMTP id da11so928118veb.27 for ; Tue, 30 Apr 2013 17:51:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=DfGgOnj7w5+2CPT9wLRaNUrybIr9zT+n5BSdu7xzE/E=; b=bFwDv479rzeU6sKrf+3kqhSn8qPfbQYcG+vPGKJSKF639utS4R34pAYq5DjEVAgD4u gfuWLE4O10aCTogdS5eIIzR4UIWMsoIorzOeDJTQ/1LL9VhrvyOps5Jjsjno3HNc9AdJ KTt1URJvHA5/FwxGkbN7aIY4jn7r0H5voAE/+8kWcXu7CqCt7a0egvIGKKszhzpnmNN4 /6w3E95neGV6n4mKtzT9eUJL/c0PleVw+6+WqF57ck3rACNxTJ04ZuU9XgUPKyvTrCDS 3Igmo6KQKkxolW5gLTQMuNMb2NePCGUoQDZisLn2t0cAn0saly+ttZn/ssSMjJUsxMI3 gWQw== MIME-Version: 1.0 X-Received: by 10.52.24.113 with SMTP id t17mr219956vdf.30.1367369499938; Tue, 30 Apr 2013 17:51:39 -0700 (PDT) Received: by 10.220.173.7 with HTTP; Tue, 30 Apr 2013 17:51:39 -0700 (PDT) In-Reply-To: <1367308142.25105.25.camel@Renee-desktop.suse> References: <1367308142.25105.25.camel@Renee-desktop.suse> Date: Wed, 01 May 2013 00:51:00 -0000 Message-ID: Subject: Re: About adding new script language From: Doug Evans To: Nala Ginrut Cc: "gdb@sourceware.org" Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQlbup4eI7RdNOOGEZOhEFUASgnN3FhluAbeg1mUmk9JJqz+vPuIoEpGwtGY3YanR4ifFzM5y6ALCZC1xXtFVVYzsOMZ8Pje2Eslf/MLaeL9oEtqyPCvRR72EgDTdwzUwfUndaOnCcjE8e9xs2rs3+V1JTdY+1nLiBKEJss6IfoaepEwNOFQZQrYsyZM2qdhhv1lF4I3 X-SW-Source: 2013-05/txt/msg00000.txt.bz2 Content-length: 2131 On Tue, Apr 30, 2013 at 12:49 AM, Nala Ginrut wrote: > Hi GDB folks! > I'm new comer here, and I'm trying to make guile the extension language. > Anyway, folks could use python as well, before guile has reliable python > front-end. > I've read the python part, here're some ideas, correct me if I'm wrong > please. ;-) > > 1. Is it necessary to use language_defn to define the extension > language? > My understanding is language_defn defines a new language support for > debugging the defined language, not to define a new extension language > for other debugging purpose. Or not? > For example, go-lang.c is the support for debugging go, not add go as > the debug script language, just like python. But it confused me that > python has used language_defn. Hi. Your interpretation of language_defn is correct. The Python extension support in GDB uses language_defn only to implement various API calls. E.g. when printing a value one might want to know the (programming) language in which to print it. > 2. There should be interfaces to add the script language, but I didn't > find it, anyone point me out? I don't think I have to write new > lexer/parser for that, just need a way to get the expr and call guile's > read function. Thanks! There aren't any interfaces, they need to be added. One of the hardest parts of adding Guile support to GDB (as an extension language) will be providing reasonable interfaces. > 3. My aim is not only add guile as an extension in gdb's REPL, but a > more powerful language for the automatic debugging. For that purpose, > the hard/heavy work is not to add guile into gdb, but a framework > project implemented by guile based on the support of guile-gdb. > Is this idea too unrealistic? It's not unrealistic. It's easier to add a second one now that the first is there. However, as I said, adding clean interfaces will be important. We want the end result to be maintainable, and supporting multiple extension languages is going to complicate things. [It will be easier in the sense that we're not interested in supporting and arbitrary number of extension languages.]