LCOV - code coverage report
Current view: directory - src/trusted/sel_universal - pnacl_emu_coordinator.cc (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 22 3 13.6 %
Date: 2012-02-16 Functions: 0 0 -

       1                 : // Copyright (c) 2011 The Native Client Authors. All rights reserved.
       2                 : // Use of this source code is governed by a BSD-style license that can be
       3                 : // found in the LICENSE file.
       4                 : //
       5                 : 
       6                 : #include <map>
       7                 : #include <string>
       8                 : 
       9                 : #include "native_client/src/shared/platform/nacl_check.h"
      10                 : #include "native_client/src/shared/platform/nacl_log.h"
      11                 : #include "native_client/src/shared/srpc/nacl_srpc.h"
      12                 : #include "native_client/src/trusted/sel_universal/pnacl_emu.h"
      13                 : #include "native_client/src/trusted/sel_universal/primitives.h"
      14                 : #include "native_client/src/trusted/sel_universal/rpc_universal.h"
      15                 : #include "native_client/src/trusted/sel_universal/srpc_helper.h"
      16                 : 
      17                 : using std::string;
      18                 : 
      19                 : namespace {
      20                 : 
      21                 : NaClCommandLoop* g_ncl;
      22                 : 
      23                 : // Maps from a saved key to the sel_universal variable name that refers to
      24                 : // a file.
      25              22 : std::map<string, string> g_key_to_varname;
      26                 : 
      27                 : // LookupInputFile:s:h
      28               0 : void LookupInputFile(SRPC_PARAMS) {
      29               0 :   string key(ins[0]->arrays.str);
      30               0 :   rpc->result = NACL_SRPC_RESULT_APP_ERROR;
      31               0 :   NaClLog(1, "LookupInputFile(%s)\n", key.c_str());
      32               0 :   if (g_key_to_varname.find(key) == g_key_to_varname.end()) {
      33               0 :     return;
      34                 :   }
      35               0 :   string varname = g_key_to_varname[key];
      36               0 :   NaClLog(1, "LookupInputFile(%s) -> %s\n", key.c_str(), varname.c_str());
      37               0 :   outs[0]->u.hval = g_ncl->FindDescByName(varname);
      38               0 :   rpc->result = NACL_SRPC_RESULT_OK;
      39               0 :   done->Run(done);
      40                 : }
      41                 : 
      42                 : }  // end namespace
      43                 : 
      44                 : 
      45                 : #define TUPLE(a, b) #a #b, a
      46               0 : void PnaclEmulateCoordinator(NaClCommandLoop* ncl) {
      47                 :   // Register file lookup RPC.
      48               0 :   ncl->AddUpcallRpc(TUPLE(LookupInputFile, :s:h));
      49               0 :   g_ncl = ncl;
      50               0 : }
      51                 : 
      52                 : void PnaclEmulateAddKeyVarnameMapping(const std::string& key,
      53               0 :                                       const std::string& varname) {
      54                 :   NaClLog(1, "AddKeyVarnameMapping(%s) -> %s\n", key.c_str(),
      55               0 :           varname.c_str());
      56               0 :   CHECK(g_key_to_varname.find(key) == g_key_to_varname.end());
      57               0 :   g_key_to_varname[string(key)] = string(varname);
      58              22 : }

Generated by: LCOV version 1.7