From patchwork Thu Sep 22 14:02:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 15920 Received: (qmail 7081 invoked by alias); 22 Sep 2016 14:02:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 7048 invoked by uid 89); 22 Sep 2016 14:02:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=Selected, Close, 2350 X-HELO: mail-wm0-f65.google.com Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Sep 2016 14:02:14 +0000 Received: by mail-wm0-f65.google.com with SMTP id w84so14275224wmg.0 for ; Thu, 22 Sep 2016 07:02:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=kTT04bQcs/mld3XXbwk3fbzEXBLs69hotTyLtqRqOuw=; b=Sgm5E1G0QOQs4dHiEKBSa64uYh0V1E/2N6pbQwhZ1o9iUXFJ0xDrRe8xJdgd4OoLQ+ ddHtLyouV9RTdH6HF77XaZgdvsAXGdhyswitrO5+59JIUt94DMBu9hVWaumnLMA/YV1J /lqtEfaKQFUttWMGLQx08QZeeoJT23kwKiiZX7IW5NrLx3ABJp7N+8dqzhS2f5updKH6 lG9PWxRH3IgQLWrGYFWk49tFpf7jvF6gNREjiRs/Gmup48ScSX3RWJGjr8Y8ZjBYTtG6 tmZdmJIr0n65WcWGDEJpcNyzDokNO49NZaUqAN/GRK9r7070xNWDa8WFgFKGhkH6L1AK hxaQ== X-Gm-Message-State: AA6/9RmwsGDF0Jd+6AIGhxXUFZWZjf8pDf8L9leoAUiE95zik8TNPVgIpYMeBAz78E78Yg== X-Received: by 10.194.72.133 with SMTP id d5mr2166665wjv.96.1474552932144; Thu, 22 Sep 2016 07:02:12 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com ([86.65.39.12]) by smtp.gmail.com with ESMTPSA id va3sm2285987wjb.18.2016.09.22.07.02.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 07:02:11 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Close gdbserver in mi_gdb_exit Date: Thu, 22 Sep 2016 15:02:02 +0100 Message-Id: <1474552922-29654-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes In commit 6423214f (testsuite: Don't use expect_background to reap gdbserver), we override gdb_exit in lib/gdbserver-support.exp, so that we can close gdbserver first. However, we don't close gdbserver in mi_gdb_exit. This makes a problem in my aarch64 multi-arch testing, in which I run some mi tests, mi-watch.exp for example, in different variations (aarch64 and arm), Schedule of variations: junor0-2 junor0-2-arm/-marm junor0-2-arm/-mthumb When the test is done in the first variation (aarch64), test case is recompiled for arm, but GDBserver with aarch64 program is still running. When the second variation is started, GDB loads arm program, but GDBserver still loads aarch64 program because the old GDBserver process is using it. We'll get, 47-target-select remote junor0-2:2350^M &"warning: Selected architecture arm is not compatible with reported target architecture aarch64\n"^M &"warning: Architecture rejected target-supplied description\n" This patch fixes this problem by closing GDBserver in mi_gdb_exit. gdb/testsuite: 2016-09-22 Yao Qi * lib/gdbserver-support.exp: Rename mi_gdb_exit. (gdb_exit): Rename it to ... (gdbserver_gdb_exit): ... Close GDBserver. (gdb_exit): New proc, call gdbserver_gdb_exit. (mi_gdb_exit): Likewise. --- gdb/testsuite/lib/gdbserver-support.exp | 35 ++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index 70c8a5f..8a42eb8 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -356,12 +356,16 @@ proc close_gdbserver {} { unset server_spawn_id } -# Hook into GDB exit, and close GDBserver. +# Hook into GDB exit, and close GDBserver. We must load this +# explicitly here, and rename the procedures we want to override. +load_lib mi-support.exp if { [info procs gdbserver_orig_gdb_exit] == "" } { rename gdb_exit gdbserver_orig_gdb_exit + rename mi_gdb_exit gdbserver_orig_mi_gdb_exit } -proc gdb_exit {} { + +proc gdbserver_gdb_exit { is_mi } { global gdb_spawn_id server_spawn_id global gdb_prompt global gdbserver_reconnect_p @@ -369,7 +373,11 @@ proc gdb_exit {} { # Leave GDBserver running if we're exiting GDB in order to # reconnect to the same instance of GDBserver again. if {[info exists gdbserver_reconnect_p] && $gdbserver_reconnect_p} { - gdbserver_orig_gdb_exit + if { $is_mi } { + gdbserver_orig_mi_gdb_exit + } else { + gdbserver_orig_gdb_exit + } return } @@ -378,7 +386,12 @@ proc gdb_exit {} { # but DejaGNU doesn't know that, so gdb_spawn_id isn't unset. # Catch the exceptions. catch { - send_gdb "monitor exit\n"; + if { $is_mi } { + set monitor_exit "-interpreter-exec console \"monitor exit\"\n" + } else { + set monitor_exit "monitor exit" + } + send_gdb "$monitor_exit\n"; # We use expect rather than gdb_expect because # we want to suppress printing exception messages, otherwise, # remote_expect, invoked by gdb_expect, prints the exceptions. @@ -395,7 +408,19 @@ proc gdb_exit {} { } close_gdbserver - gdbserver_orig_gdb_exit + if { $is_mi } { + gdbserver_orig_mi_gdb_exit + } else { + gdbserver_orig_gdb_exit + } +} + +proc gdb_exit {} { + gdbserver_gdb_exit 0 +} + +proc mi_gdb_exit {} { + gdbserver_gdb_exit 1 } # Start a gdbserver process running HOST_EXEC and pass CHILD_ARGS