Path: utzoo!mnetor!uunet!husc6!uwvax!oddjob!ncar!ames!oliveb!sun!gorodish!guy From: guy@gorodish.Sun.COM (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: sun-3 dbx, arguments, hacking, help... Message-ID: <50709@sun.uucp> Date: 25 Apr 88 16:05:20 GMT References: <1641@homxb.UUCP> Sender: news@sun.uucp Lines: 23 Keywords: Kludge, Hack, Hack > HELP!!! I need to know how `dbx' knows how many arguments are on the > stack when you do the `where' command on a SUN 3. By looking at the code following the call to see how many bytes it pops off the stack. (I checked the "dbx" source.) > Now, dbx KNOWS how many 4 byte arguments are there. You do not have > to compile with -g, and it does not look in a symbol table and see how many > are supposed to be there, it knows even for function with a variable number > of arguments. Try the following program: I did, and discovered that it does *not* get the argument count right on the last call, because, as you indicate, the optimizer gets rid of the stack-cleaning code. It thinks "go" was called with zero arguments in the last call. > P.S. > This will probably be impossible on a SUN-4 Make that "certainly will be impossible on a Sun-4", or on any other machine that 1) passes arguments in registers and 2) has a compiler that does sufficient optimization. Perhaps not impossible, but at least *extremely* difficult.