[oss] [Assignment 1][Task 1] GDB - Ambiguities
Vlad Dumitrescu
vlad at dumitrescu.ro
Tue Nov 24 19:56:04 EET 2015
Hi,
On Mon, Nov 23, 2015 at 1:52 PM, Andrei Datcu <datcuandrei at gmail.com> wrote:
> On the 4th subtask we have to:
> "break on malloc calls; print the return value after malloc finishes"
>
> So, we have to break on every malloc call? What's the point, as the
> program only calls it once? Also, malloc is recursive. How do we
> handle that? What return value do we have to print? Do we have to
> print each return value after each recursive call?
The recursive part exceeds my level of knowledge about malloc. Is the
entry point (i.e., malloc()) recursive, or just some internal helpers?
There is indeed a single call to malloc(), but I think it is reached
via 2 paths. The returned value to be printed is the pointer you "see"
in alloc_hash(). Does this make sense?
> On the 9th subtask, we have to:
> "break execution on printf calls while in this mode
> print current frame and the EIP register each time this breakpoint triggers"
>
> Again, do we have to break each printf call? If so, do we have to do a
> conditional and only hit the breakpoint if the flag is is set in a
> stack frame below the current one? What do you mean by printing the
> current frame?
Yes, use a conditional as "while in this mode" suggests. From GDB
manual (which I think it is linked in the assignment): "Without an
argument, frame prints the current stack frame". Does this make it
more clear?
In general, it is perfectly fine to make any assumptions for this
task; use common sense, and document them in comments. Don't spend too
much time on it as its purpose is to be a GDB 101 in case you never
used it before.
Vlad
More information about the oss
mailing list