From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Elizabeth Chastain To: fnasser@cygnus.com, msnyder@cygnus.com Cc: gdb-patches@sources.redhat.com, keiths@cygnus.com Subject: Re: [RFA] Assuming malloc exists in callfwmall.exp Date: Wed, 14 Feb 2001 13:41:00 -0000 Message-id: <200102142140.NAA29810@bosch.cygnus.com> X-SW-Source: 2001-02/msg00225.html > But how is it possible that GDB needs malloc() when the target does not > have it? (gdb) print strlen("foo") GDB needs some mechanism to grab scratch memory in the target. malloc() is the only mechanism that it has. Michael /* gdb/valops.c */ /* Allocate NBYTES of space in the inferior using the inferior's malloc and return a value that is a pointer to the allocated space. */ value_ptr value_allocate_space_in_inferior (int len) { value_ptr blocklen; register value_ptr val = find_function_in_inferior ("malloc"); blocklen = value_from_longest (builtin_type_int, (LONGEST) len); val = call_function_by_hand (val, 1, &blocklen); if (value_logical_not (val)) { if (!target_has_execution) error ("No memory available to program now: you need to start the target first"); else error ("No memory available to program: call to malloc failed"); } return val; }