From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from h2828900.stratoserver.net (h2828900.stratoserver.net [81.169.236.69]) by sourceware.org (Postfix) with ESMTP id 178243858401 for ; Sat, 14 Aug 2021 10:28:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 178243858401 Received: from [192.168.0.251] (ip5f5accc7.dynamic.kabel-deutschland.de [95.90.204.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: max@schneidersoft.net) by h2828900.stratoserver.net (Postfix) with ESMTPSA id BE36134044A for ; Sat, 14 Aug 2021 12:28:51 +0200 (CEST) Message-ID: Subject: GDB call and p func() on embedded target From: Maximilian Schneider To: gdb@sourceware.org Date: Sat, 14 Aug 2021 11:28:46 +0100 Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Aug 2021 10:28:54 -0000 Hello, I am trying to call a function from withing a gdb debugging session on an embedded target. However gdb never returns and when i stop it manually the program counter is in a strange place. It appears that gdb is not able to catch the return, and is continuing execution from before the core was halted... assume the function I want to call has prototype int32_t Init(void); If I set the pc manually I can step throught the function until the return without a problem. I can even set a breakpoint on Init and then use p Init(). The breakpoint will fire and I can step throught the code manually. eg. target remote localhost:3333 monitor reset halt monitor reset init file loader.elf load loader.elf set $sp=0x20010000 set $pc=&Init b Init p Init() n n n ... However without the breakpoint gdb never returns. Is this a known problem? Is there a workaround? Some background: The purpose of this entire excercise is to arrive at a tool/set of scripts that can be used to load and execute arbitrary code from RAM, to fi. manipulate external memories or run tests. Regards, M