From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Received: (qmail 9596 invoked from network); 9 Jan 2003 16:50:06 -0000 Received: from unknown (HELO localhost.redhat.com) (216.138.202.10) by 209.249.29.67 with SMTP; 9 Jan 2003 16:50:06 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 938EB3EC2; Thu, 9 Jan 2003 11:49:56 -0500 (EST) Message-ID: <3E1DA834.5060906@redhat.com> Date: Thu, 09 Jan 2003 16:50:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.1) Gecko/20021211 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb@sources.redhat.com Subject: Re: Failures in store.exp caused by regcache References: <20030108190506.GA558@nevyn.them.org> <3E1C77B4.8070401@redhat.com> <20030109032346.GA10532@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-01/txt/msg00133.txt.bz2 > On Wed, Jan 08, 2003 at 02:10:44PM -0500, Andrew Cagney wrote: > >> >(Or rather, by the value code's interaction with the regcache) >> > >> >Andrew, this is more your area; I'd like your advice before I dig any >> >further. Here's what's going wrong. Consider the command sequence: >> >"up; print u; set u = s_1; print u". >> > - u has class LOC_REGISTER >> > - The register's home is memory >> > - read_var_value therefore returns an lval_memory >> > - the value of the register is in the register unwind cache at this point >> > - we modify the memory backing the store >> > - we have no way to tell that we've just modified the value of a saved >> > register on the stack >> > - the second print returns the cached value >> > >> >So, what do we do? > >> >> Flush the frame cache. > > > Ugg. Well, if we have to, then we have to. I suppose we do. It isn't that bad. In fact (per previous discussion), the code needed to avoid flushing the caches would be far worse than what we have now. The only time the frame cache gets (well, ok, should get ...) flushed is: - when the target resumes The recovery time here is critical. - when the target is modified The recovery time here is bounded by the recovery time from a target resume. People `never' modify the target. That leaves the time taken to recover from a resume and then: - we must flush the cache - since it is an upper bound on target modify recovery time, making it faster is a win win. > We obviously want to preserve things like the selected frame, however. I'm actually a bit puzzled. I recently fixed a case and added a testcase (store.exp) that handles stores. Look for frame_find_by_id() in valops.c. > Andrew, should I do this the way I do for "set backtrace-below-main", > and should there be a general function for that? I.E.: Have a look at the comments in "frame.h" around reinit_frame_cache() and get_selected_frame(). In particular: FIXME: cagney/2002-11-28: The only difference between flush_cached_frames() and reinit_frame_cache() is that the latter explicitly sets the selected frame back to the current frame there isn't any real difference (except that one delays the selection of a new frame). Code can instead simply rely on get_selected_frame() to reinit's the selected frame as needed. As for invalidating the cache, there should be two methods one that reverts the thread's selected frame back to current frame (for when the inferior resumes) and one that does not (for when the user modifies the target invalidating the frame cache). */ /* FIXME: cagney/2002-11-28: At present, when there is no selected frame, this function always returns the current (inner most) frame. It should instead, when a thread has previously had its frame selected (but not resumed) and the frame cache invalidated, find and then return that thread's previously selected frame. */ This only works if we're storing the selected frame in the selected thread. Unfortunatly (arrrrrrg), GDB first needs to be convinced that `there is always a thread' so that there is always a `struct thread_info' into which the selected frame's id can be stored (or, I guess, as a temp, extend the existing `there might be a thread' hack to handle this case, double arrrrg). The below does raise an interesting question: > void > do_flush_frames_sfunc (char *args, int from_tty, struct cmd_list_element *c) > { > int saved_level; > struct frame_info *cur_frame; > > if (! target_has_stack) > return; > > saved_level = frame_relative_level (get_selected_frame ()); > > flush_cached_frames (); > > cur_frame = find_relative_frame (get_current_frame (), &saved_level); > select_frame (cur_frame); > > /* If we were below main and backtrace-below-main was turned off, > SAVED_LEVEL will be non-zero. CUR_FRAME will point to main. > Accept this but print the new frame. */ > if (saved_level != 0) > print_stack_frame (get_selected_frame (), -1, 0); > } what should: (gdb) set backtrace-below-main on (gdb) up ; up ; up (gdb) set backtrace-below-main off (gdb) set variable x = 1 do? get_next_frame() is going to refuse to go beyond main, no matter how many times you try. (btw, a frame_id is safer than a level). Andrew