From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24998 invoked by alias); 23 Apr 2003 15:17:21 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24991 invoked from network); 23 Apr 2003 15:17:20 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 23 Apr 2003 15:17:20 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 486742B2F for ; Wed, 23 Apr 2003 11:17:19 -0400 (EDT) Message-ID: <3EA6AE7F.7060708@redhat.com> Date: Wed, 23 Apr 2003 19:12:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [commit] infcall.c cleanup - explict bp_addr variable Content-Type: multipart/mixed; boundary="------------010003040108050001020700" X-SW-Source: 2003-04/txt/msg00439.txt.bz2 This is a multi-part message in MIME format. --------------010003040108050001020700 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 587 Hello, This patch cleans up just one tiny part of the new merged call_function_by_hand(). It teases out an explicit "bp_addr" variable that contains the address of the breakpoint that the called function is to return to. By doing this certain logic (such as the computation of sal.pc used to create the breakpoint) is simplified; and other logic (such as the initial computation of the "bp_addr") is localized. The only depressing bit in this cleanup is that it is now pretty clear how messed up the logic to compute the ON_STACK breakpoint addr has become. committed, Andrew --------------010003040108050001020700 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 5121 2003-04-22 Andrew Cagney * infcall.c (call_function_by_hand): Use new variable "bp_addr" to compute the breakpoint address. Only call FIX_CALL_DUMMY when ON_STACK. Eliminate the variable "addr". Do not pass "real_pc" to DEPRECATED_PUSH_RETURN_ADDRESS. Index: infcall.c =================================================================== RCS file: /cvs/src/src/gdb/infcall.c,v retrieving revision 1.1 diff -u -r1.1 infcall.c --- infcall.c 21 Apr 2003 16:48:39 -0000 1.1 +++ infcall.c 23 Apr 2003 14:58:16 -0000 @@ -272,6 +272,7 @@ struct type *param_type = NULL; struct type *ftype = check_typedef (SYMBOL_TYPE (function)); int n_method_args = 0; + CORE_ADDR bp_addr; dummy = alloca (SIZEOF_CALL_DUMMY_WORDS); sizeof_dummy1 = REGISTER_SIZE * SIZEOF_CALL_DUMMY_WORDS / sizeof (ULONGEST); @@ -413,23 +414,33 @@ REGISTER_SIZE, (ULONGEST) dummy[i]); -#ifdef GDB_TARGET_IS_HPPA - real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, - value_type, using_gcc); -#else - if (FIX_CALL_DUMMY_P ()) - { - /* gdb_assert (CALL_DUMMY_LOCATION == ON_STACK) true? */ - FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, value_type, - using_gcc); - } - real_pc = start_sp; -#endif - switch (CALL_DUMMY_LOCATION) { case ON_STACK: + /* NOTE: cagney/2003-04-22: This computation of REAL_PC, BP_ADDR + and DUMMY_ADDR is pretty messed up. It comes from constant + tinkering with the values. Instead a FIX_CALL_DUMMY + replacement (PUSH_DUMMY_BREAKPOINT?) should just do + everything. */ +#ifdef GDB_TARGET_IS_HPPA + real_pc = FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, + value_type, using_gcc); +#else + if (FIX_CALL_DUMMY_P ()) + { + /* gdb_assert (CALL_DUMMY_LOCATION == ON_STACK) true? */ + FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, value_type, + using_gcc); + } + real_pc = start_sp; +#endif dummy_addr = start_sp; + /* Yes, the offset is applied to the real_pc and not the dummy + addr. Ulgh! Blame the HP/UX target. */ + bp_addr = real_pc + CALL_DUMMY_BREAKPOINT_OFFSET; + /* Yes, the offset is applied to the real_pc and not the + dummy_addr. Ulgh! Blame the HP/UX target. */ + real_pc += CALL_DUMMY_START_OFFSET; write_memory (start_sp, (char *) dummy1, sizeof_dummy1); if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES) generic_save_call_dummy_addr (start_sp, start_sp + sizeof_dummy1); @@ -437,6 +448,9 @@ case AT_ENTRY_POINT: real_pc = funaddr; dummy_addr = CALL_DUMMY_ADDRESS (); + /* A call dummy always consists of just a single breakpoint, so + it's address is the same as the address of the dummy. */ + bp_addr = dummy_addr; if (DEPRECATED_USE_GENERIC_DUMMY_FRAMES) /* NOTE: cagney/2002-04-13: The entry point is going to be modified with a single breakpoint. */ @@ -649,7 +663,13 @@ return-address register as appropriate. Formerly this has been done in PUSH_ARGUMENTS, but that's overloading its functionality a bit, so I'm making it explicit to do it here. */ - sp = DEPRECATED_PUSH_RETURN_ADDRESS (real_pc, sp); + /* NOTE: cagney/2003-04-22: The first parameter ("real_pc") has + been replaced with zero, it turns out that no implementation + used that parameter. This occured because the value being + supplied - the address of the called function's entry point + instead of the address of the breakpoint that the called + function should return to - wasn't useful. */ + sp = DEPRECATED_PUSH_RETURN_ADDRESS (0, sp); /* NOTE: cagney/2003-03-23: Diable this code when there is a push_dummy_call() method. Since that method will have already @@ -745,7 +765,6 @@ eventually be popped when we do hit the dummy end breakpoint). */ - CORE_ADDR addr = real_pc + CALL_DUMMY_START_OFFSET; struct regcache *buffer = retbuf; struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0); int saved_async = 0; @@ -756,22 +775,7 @@ clear_proceed_status (); init_sal (&sal); /* initialize to zeroes */ - if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT) - { - sal.pc = CALL_DUMMY_ADDRESS (); - } - else - { - /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need - to put a breakpoint instruction. If not, the call dummy - already has the breakpoint instruction in it. - - ADDR IS THE ADDRESS of the call dummy plus the - CALL_DUMMY_START_OFFSET, so we need to subtract the - CALL_DUMMY_START_OFFSET. */ - sal.pc = (addr - (CALL_DUMMY_START_OFFSET - + CALL_DUMMY_BREAKPOINT_OFFSET)); - } + sal.pc = bp_addr; sal.section = find_pc_overlay (sal.pc); { @@ -797,7 +801,7 @@ if (target_can_async_p ()) saved_async = target_async_mask (0); - proceed (addr, TARGET_SIGNAL_0, 0); + proceed (real_pc, TARGET_SIGNAL_0, 0); if (saved_async) target_async_mask (saved_async); --------------010003040108050001020700--