From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18354 invoked by alias); 18 Jun 2015 12:53:18 -0000 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 Received: (qmail 18338 invoked by uid 89); 18 Jun 2015 12:53:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_40,LIKELY_SPAM_SUBJECT,RP_MATCHES_RCVD,SPF_PASS autolearn=no version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Jun 2015 12:53:14 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 18 Jun 2015 05:53:11 -0700 X-ExtLoop1: 1 Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by orsmga001.jf.intel.com with ESMTP; 18 Jun 2015 05:53:10 -0700 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.171]) by IRSMSX151.ger.corp.intel.com ([169.254.4.108]) with mapi id 14.03.0224.002; Thu, 18 Jun 2015 13:53:10 +0100 From: "Tedeschi, Walfred" To: "Pedro Alves (palves@redhat.com)" CC: "gdb-patches@sourceware.org" Subject: FW: [ping] [PATCH] In MI mode -var-create --language not working. Date: Thu, 18 Jun 2015 12:53:00 -0000 Message-ID: Content-Type: multipart/mixed; boundary="_002_AC542571535E904D8E8ADAE745D60B1944430663IRSMSX104gercor_" MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00387.txt.bz2 --_002_AC542571535E904D8E8ADAE745D60B1944430663IRSMSX104gercor_ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-length: 12309 Pedro, =46rom the MI side Vladimir reported to be ok with the change. May I push? Thanks and regards, -Fred -----Original Message----- From: Tedeschi, Walfred Sent: Thursday, April 23, 2015 11:37 AM To: palves@redhat.com; vladimir@codesourcery.com Cc: gdb-patches@sourceware.org; Tedeschi, Walfred Subject: [PATCH v2] In MI mode -var-create --language not working. Pedro, I have looked for potential users of the same fix, could not find though. Though I was suspicious about the a routine prepare_re_set_context on the b= reakpoint file. However there was no clean-up routine there what made me t= hink that the code was already taking care of language on the right way. All other changes should have been addressed. Thanks a lot for your review and sorry for the delay. Regards, -Fred Trying to use --language to create a variable showed that --language was no= t always working. In some cases GDB understands that the language is autom= atic and cannot parse the language set while executing the command. In order to fix this just before executing the command language mode should= be set to manual. In this way GDB can parse the expression using the lang= uage given in the command. To do so mode has temporarily to be changed to manual expressing that any e= valuation done using the language parameter has priority over the automatic= one. Tests are also included doing evaluations when the default language is c/c+= + and when default language is Fortran. 2014-07-25 Walfred Tedeschi * utils.c (saved_language_and_mode): New. (do_restore_current_language): Add language and mode to be restored. (make_cleanup_restore_current_language): Pass the mode and language to do_restore_current_language. gdb/mi * mi-main.c (mi_cmd_execute): When --language is present set language mode to manual. gdb/testsuite: * gdb.mi/mi-language-c.cc: New file. * gdb.mi/mi-language-c.exp: New file. * gdb.mi/mi-language-fortran.cc: New file. * gdb.mi/mi-language-fortran.exp: New file. --- gdb/mi/mi-main.c | 1 + gdb/testsuite/gdb.mi/mi-language-c.cc | 36 +++++++++++++++++ gdb/testsuite/gdb.mi/mi-language-c.exp | 60 ++++++++++++++++++++++++= ++++ gdb/testsuite/gdb.mi/mi-language-fortran.exp | 54 +++++++++++++++++++++++++ gdb/testsuite/gdb.mi/mi-language-fortran.f90 | 38 ++++++++++++++++++ gdb/utils.c | 24 ++++++++--- 6 files changed, 207 insertions(+), 6 deletions(-) create mode 100644 gdb= /testsuite/gdb.mi/mi-language-c.cc create mode 100644 gdb/testsuite/gdb.mi/mi-language-c.exp create mode 100644 gdb/testsuite/gdb.mi/mi-language-fortran.exp create mode 100644 gdb/testsuite/gdb.mi/mi-language-fortran.f90 diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 59717ca..0198981 100= 644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2236,6 +2236,7 @@ mi_cmd_execute (struct mi_parse *parse) if (parse->language !=3D language_unknown) { make_cleanup_restore_current_language (); + language_mode =3D language_mode_manual; set_language (parse->language); } =20 diff --git a/gdb/testsuite/gdb.mi/mi-language-c.cc b/gdb/testsuite/gdb.mi/m= i-language-c.cc new file mode 100644 index 0000000..0c8bd42 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-language-c.cc @@ -0,0 +1,36 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2014 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see=20 + . */ + +struct A +{ + virtual ~A (); + int a1; +}; + +A::~A () +{ + a1 =3D 800; +} + +int +main (void) +{ + A alpha; + alpha.a1 =3D 100; + + return alpha.a1; /* only bp. */ +} diff --git a/gdb/testsuite/gdb.mi/mi-language-c.exp b/gdb/testsuite/gdb.mi/= mi-language-c.exp new file mode 100644 index 0000000..00f5210 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-language-c.exp @@ -0,0 +1,60 @@ +# Copyright 2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify=20 +# it under the terms of the GNU General Public License as published by=20 +# the Free Software Foundation; either version 3 of the License, or #=20 +(at your option) any later version. +# +# This program is distributed in the hope that it will be useful, # but=20 +WITHOUT ANY WARRANTY; without even the implied warranty of #=20 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU=20 +General Public License for more details. +# +# You should have received a copy of the GNU General Public License #=20 +along with this program. If not, see . + +if { [skip_cplus_tests] } { continue } + +load_lib mi-support.exp +set MIFLAGS "-i=3Dmi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +standard_testfile .cc + +if [get_compiler_info "c++"] { + return -1 +} + +if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug=20 +c++}] !=3D ""} { + untested $testfile.exp + return -1 +} + +mi_gdb_load ${binfile} + +if ![mi_run_to_main] { + untested "could not run to main" + return -1 +} + +set lineno [gdb_get_line_number "only bp."] + +mi_create_breakpoint "$srcfile:$lineno" "add mi-language1 bp" keep {main\(= \)} \ + "$srcfile" $lineno $hex "create break at main" + +mi_execute_to "exec-continue" "breakpoint-hit" \ + "main" "" ".*" ".*" {"" "disp=3D\"keep\""} \ + "continue to main bp" + +mi_gdb_test "-var-create --language fortran alpha_1 * (alpha%a1)" \ + "\\^done,name=3D\"alpha_1\",numchild=3D\"0\",value=3D\"100\",t= ype=3D\"int\",thread-id=3D\"\[0-9\]+\",has_more=3D\"0\"" \ + "-var-create from c using fortran language" + +mi_gdb_test "-var-create alpha_2 * (alpha.a1)" \ + "\\^done,name=3D\"alpha_2\",numchild=3D\"0\",value=3D\"100\",t= ype=3D\"int\",thread-id=3D\"\[0-9\]+\",has_more=3D\"0\"" \ + "-var-create from c using default language" +gdb_exit \ No newline at end of file diff --git a/gdb/testsuite/gdb.mi/mi-language-fortran.exp b/gdb/testsuite/g= db.mi/mi-language-fortran.exp new file mode 100644 index 0000000..1f38a7b --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-language-fortran.exp @@ -0,0 +1,54 @@ +# Copyright 2015 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify=20 +# it under the terms of the GNU General Public License as published by=20 +# the Free Software Foundation; either version 3 of the License, or #=20 +(at your option) any later version. +# +# This program is distributed in the hope that it will be useful, # but=20 +WITHOUT ANY WARRANTY; without even the implied warranty of #=20 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU=20 +General Public License for more details. +# +# You should have received a copy of the GNU General Public License #=20 +along with this program. If not, see . + +load_lib mi-support.exp +set MIFLAGS "-i=3Dmi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +standard_testfile .f90 + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable= \ + {debug f90}] !=3D "" } { + untested mi-language-fortran.exp + return -1 +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir mi_gdb_load ${binfile} + +set bp_lineno [gdb_get_line_number "only bp"] + +mi_create_breakpoint "-t $srcfile:$bp_lineno" "add bp"\ + "del" "struct_test" ".*$srcfile" $bp_lineno $hex \ + "MI-language-fortran insert breakpoint at line $bp_lineno (only bp)" + +mi_run_cmd + +mi_expect_stop "breakpoint-hit" "struct_test" "" ".*$srcfile" \ + "$bp_lineno" { "" "disp=3D\"del\"" } "run to bp" + +mi_gdb_test "-var-create --language c alpha_1 * (p.c)" \ + "\\^done,name=3D\"alpha_1\",numchild=3D\"0\",value=3D\"1\",typ= e=3D\"integer\\(kind=3D4\\)\",thread-id=3D\"\[0-9\]+\",has_more=3D\"0\"" \ + "-var-create from fortran using fortran language" + +mi_gdb_test "-var-create alpha_2 * (p%c)" \ + "\\^done,name=3D\"alpha_2\",numchild=3D\"0\",value=3D\"1\",typ= e=3D\"integer\\(kind=3D4\\)\",thread-id=3D\"\[0-9\]+\",has_more=3D\"0\"" \ + "-var-create from fortran using default language" +gdb_exit diff --git a/gdb/testsuite/gdb.mi/mi-language-fortran.f90 b/gdb/testsuite/g= db.mi/mi-language-fortran.f90 new file mode 100644 index 0000000..f24d7d9 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-language-fortran.f90 @@ -0,0 +1,38 @@ +! Copyright 2006-2014 Free Software Foundation, Inc. +! +! This program is free software; you can redistribute it and/or modify=20 +! it under the terms of the GNU General Public License as published by=20 +! the Free Software Foundation; either version 3 of the License, or !=20 +(at your option) any later version. +! +! This program is distributed in the hope that it will be useful, ! but=20 +WITHOUT ANY WARRANTY; without even the implied warranty of !=20 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU=20 +General Public License for more details. +! +! You should have received a copy of the GNU General Public License !=20 +along with this program. If not, see . + + +program struct_test + + type bar + integer :: c + real :: d + end type + type foo + real :: a + type(bar) :: x + character*7 :: b + end type foo + type(foo) :: q + type(bar) :: p + + p =3D bar(1, 2.375) + q%a =3D 3.125 + q%b =3D "abcdefg" + q%x%c =3D 1 + q%x%d =3D 2.375 + print *,p,q ! only bp + +end program struct_test diff --git a/gdb/utils.c b/gdb/utils.c index 4da9501..cffa399 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -444,24 +444,36 @@ make_cleanup_free_so (struct so_list *so) =20 /* Helper for make_cleanup_restore_current_language. */ =20 +struct saved_language_and_mode +{ + enum language lang; + enum language_mode mode; +}; + static void do_restore_current_language (void *p) { - enum language saved_lang =3D (uintptr_t) p; + struct saved_language_and_mode *lang_and_mode =3D p; enum language=20 + saved_lang =3D lang_and_mode->lang; =20 + language_mode =3D lang_and_mode->mode; set_language (saved_lang); } =20 -/* Remember the current value of CURRENT_LANGUAGE and make it restored when - the cleanup is run. */ +/* Remember the current value of CURRENT_LANGUAGE and + LANGUAGE_MODE restoring them when the cleanup is run. */ =20 struct cleanup * make_cleanup_restore_current_language (void) { - enum language saved_lang =3D current_language->la_language; + struct saved_language_and_mode *lang_and_mode + =3D XNEW (struct saved_language_and_mode); + + lang_and_mode->lang =3D current_language->la_language;=20=20 + lang_and_mode->mode =3D language_mode; =20 - return make_cleanup (do_restore_current_language, - (void *) (uintptr_t) saved_lang); + return make_cleanup_dtor (do_restore_current_language, + (void *) lang_and_mode, xfree); } =20 /* Helper function for make_cleanup_clear_parser_state. */ -- 2.1.0 Intel GmbH Dornacher Strasse 1 85622 Feldkirchen/Muenchen, Deutschland Sitz der Gesellschaft: Feldkirchen bei Muenchen Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk Registergericht: Muenchen HRB 47456 Ust.-IdNr./VAT Registration No.: DE129385895 Citibank Frankfurt a.M. (BLZ 5= 02 109 00) 600119052 Intel GmbH Dornacher Strasse 1 85622 Feldkirchen/Muenchen, Deutschland Sitz der Gesellschaft: Feldkirchen bei Muenchen Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk Registergericht: Muenchen HRB 47456 Ust.-IdNr./VAT Registration No.: DE129385895 Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052 --_002_AC542571535E904D8E8ADAE745D60B1944430663IRSMSX104gercor_ Content-Type: message/rfc822 Content-Disposition: attachment; creation-date="Thu, 18 Jun 2015 12:53:09 GMT"; modification-date="Thu, 18 Jun 2015 12:53:09 GMT" Content-length: 4703 Received: from orsmsx103.amr.corp.intel.com (10.22.225.130) by IRSMSX101.ger.corp.intel.com (163.33.3.153) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 12 Nov 2014 06:29:02 +0000 Received: from orsmga001.jf.intel.com (10.7.209.18) by ORSMSX103-1.jf.intel.com (10.22.225.130) with Microsoft SMTP Server id 14.3.195.1; Tue, 11 Nov 2014 22:29:00 -0800 Received: from fmsmga102.fm.intel.com ([10.1.193.69]) by orsmga001-1.jf.intel.com with ESMTP; 11 Nov 2014 22:28:47 -0800 Received: from server1.sourceware.org (HELO sourceware.org) ([209.132.180.131]) by mga11.intel.com with ESMTP; 11 Nov 2014 22:28:46 -0800 Received: (qmail 11301 invoked by alias); 12 Nov 2014 06:28:43 -0000 Received: (qmail 11289 invoked by uid 89); 12 Nov 2014 06:28:42 -0000 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Nov 2014 06:28:40 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XoRPw-0003Au-Rn from Vladimir_Prus@mentor.com ; Tue, 11 Nov 2014 22:28:37 -0800 Received: from [172.30.1.169] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.181.6; Wed, 12 Nov 2014 06:28:35 +0000 From: Vladimir Prus To: "Tedeschi, Walfred" CC: "gdb-patches@sourceware.org" Subject: Re: FW: [ping] [PATCH] In MI mode -var-create --language not working. Thread-Topic: FW: [ping] [PATCH] In MI mode -var-create --language not working. Thread-Index: Ac/4RxG1JtLxcGmYQJO5jbvpYkhpSQAAPqQwAX53vYA= Sender: "gdb-patches-owner@sourceware.org" Date: Wed, 12 Nov 2014 06:28:49 +0000 Message-ID: <5462FE21.7090307@codesourcery.com> References: List-Help: , List-Subscribe: List-Unsubscribe: In-Reply-To: Content-Language: en-US X-MS-Exchange-Organization-AuthSource: ORSMSX103.amr.corp.intel.com X-MS-Has-Attach: X-Auto-Response-Suppress: All X-MS-TNEF-Correlator: x-ironport-av: E=Sophos;i="5.07,367,1413270000"; d="scan'208";a="1482932223" x-ironport-anti-spam-result: AoIBAE39YlTRhLSDnGdsb2JhbABcg2JZy3weCokBAQEBAQEBEAEBAQEBCAsJCRQuhAIBAQEBAwECNQgDAQIyAQEBBAECAQUBAQoYCRYPAwEBBAMCAQIBPAkGDQECBQEBAYg8BQi2C4YDApE1DAEYAQaVZgGMCYsIjyGSaWqCSwEBAQ x-ironport-anti-spam-filtered: true list-id: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 list-post: delivered-to: mailing list gdb-patches@sourceware.org list-archive: dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; s=default; bh=/FqSkLlfW3rC7xP1oWF6aq nctjI=; b=Bopyw5yUFdb7FGs/VVbftvWJFibClw/MZi//3DUROIyqdCzF1vv8Qz 8Bra/GEeERe1tULdJhaWQs3PP6BGsPkTQa9RMFXlhHgbvjvlW0r39FGzmWEK319X epDhqPp885/pJjTb8Ns3ajW6B5AntJ8vFYMkSHF3C7HMn6sCcrCpw= domainkey-signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=LpqO7MJVDIMS1IsJ HpFZKWsaDPMOuWMaWEe0Xl85Lq5ZCBRaC8xpW2ViJvx5EG56uUx71iD9/xz8wpIT RkdtKuWdUJdburMgHkOeFOeVl+/j4SbhdeYfUB3Iue+M1QrrMXD94q98zTBvd8Wa ujyZrG0wsKVbvAStwbFWr2P3NCQ= authentication-results: sourceware.org; auth=none mailing-list: contact gdb-patches-help@sourceware.org; run by ezmlm Content-Type: text/plain; charset="Windows-1252" Content-ID: <36A5C7BA0151CC4D98634D8DC89881AB@intel.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-length: 428 On 11/04/2014 06:57 PM, Tedeschi, Walfred wrote: > Hello Vladimir, > > This is not really a ping, first one I have sent to the wrong maintainer= . (sorry) > > Any feedback on that: > https://sourceware.org/ml/gdb-patches/2014-09/msg00868.html Hi Fred, I've looked at the patch above, and have no objections to MI parts of it. Thanks, -- Vladimir Prus CodeSourcery / Mentor Embedded http://www.mentor.com/embedded-software/ --_002_AC542571535E904D8E8ADAE745D60B1944430663IRSMSX104gercor_--