<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Can't easily call a function in a binary without debug information, even if I can break on it"
   href="http://llvm.org/bugs/show_bug.cgi?id=22211">22211</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Can't easily call a function in a binary without debug information, even if I can break on it
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mstange@themasta.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'd like to easily be able to attach lldb to a Firefox Nightly build and call a
function called mozilla_sampler_save_profile_to_file, like this:

<span class="quote">> (lldb) print (void)mozilla_sampler_save_profile_to_file("/Users/mstange/Desktop/profile.txt")</span >

But since this binary doesn't come with debugging information, lldb gives me an
error:
<span class="quote">> error: use of undeclared identifier 'mozilla_sampler_save_profile_to_file'</span >

It can, however, break on the  function:
<span class="quote">> (lldb) b mozilla_sampler_save_profile_to_file
> Breakpoint 1: where = XUL`mozilla_sampler_save_profile_to_file(char const*), address = 0x000000010253d2a0</span >

As a user of lldb, I can now take that address, cast it to a function pointer,
and call the function through that pointer:
<span class="quote">> (lldb) p ((void(*)(const char*))0x000000010253d2a0)("/Users/mstange/Desktop/profile.txt")</span >

Or, instead of copy-pasting the address, I can do a little scripting:
<span class="quote">> (lldb) script
> Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
> >>> lldb.debugger.HandleCommand('print ((void(*)(const char*))0x%0x)("/Users/mstange/Desktop/profile.txt")' % lldb.target.FindFunctions("mozilla_sampler_save_profile_to_file").symbols[0].addr.load_addr)</span >

It would be nice if lldb could simplify this process for me. It knows the
address of the function already, and it could theoretically derive the argument
types from the demangled function name.

In <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1118228">https://bugzilla.mozilla.org/show_bug.cgi?id=1118228</a> I'm adding a user
defined lldb function called 'callfunc' to the lldb helpers that are included
in the Firefox source, which makes this a little easier.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>