<commit_before>
#include <sys/wait.h>
#include <algorithm>

#include "config/gems_root.hh"
#include "mem/ruby/libruby_internal.hh"
#include "mem/ruby/system/RubyPort.hh"
#include "mem/ruby/system/System.hh"
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
#include "mem/ruby/system/MemoryVector.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/recorder/Tracer.hh"

string RubyRequestType_to_string(const RubyRequestType& obj)
{
  switch(obj) {
  case RubyRequestType_IFETCH:
    return "IFETCH";
  case RubyRequestType_LD:
    return "LD";
  case RubyRequestType_ST:
    return "ST";
  case RubyRequestType_Locked_Read:
    return "Locked_Read";
  case RubyRequestType_Locked_Write:
    return "Locked_Write";
  case RubyRequestType_RMW_Read:
    return "RMW_Read";
  case RubyRequestType_RMW_Write:
    return "RMW_Write";
  case RubyRequestType_NULL:
  default:
    assert(0);
    return "";
  }
}

RubyRequestType string_to_RubyRequestType(std::string str)
{
  if (str == "IFETCH")
    return RubyRequestType_IFETCH;
  else if (str == "LD")
    return RubyRequestType_LD;
  else if (str == "ST")
    return RubyRequestType_ST;
  else if (str == "Locked_Read")
    return RubyRequestType_Locked_Read;
  else if (str == "Locked_Write")
    return RubyRequestType_Locked_Write;
  else if (str == "RMW_Read")
    return RubyRequestType_RMW_Read;
  else if (str == "RMW_Write")
    return RubyRequestType_RMW_Write;
  else
    assert(0);
  return RubyRequestType_NULL;
}

ostream& operator<<(ostream& out, const RubyRequestType& obj)
{
  out << RubyRequestType_to_string(obj);
  out << flush;
  return out;
}

ostream& operator<<(std::ostream& out, const RubyRequest& obj)
{
  out << hex << "0x" << obj.paddr << flush;
  return out;
}

vector<string> tokenizeString(string str, string delims)
{
  vector<string> tokens;
  char* pch;
  char* tmp;
  const char* c_delims = delims.c_str();
  tmp = new char[str.length()+1];
  strcpy(tmp, str.c_str());
  pch = strtok(tmp, c_delims);
  while (pch != NULL) {
    string tmp_str(pch);
    if (tmp_str == "null") tmp_str = "";
    tokens.push_back(tmp_str);

    pch = strtok(NULL, c_delims);
  }
  delete [] tmp;<commit_msg>ruby: added data print to ruby request<commit_after>
#include <sys/wait.h>
#include <algorithm>

#include "config/gems_root.hh"
#include "mem/ruby/libruby_internal.hh"
#include "mem/ruby/system/RubyPort.hh"
#include "mem/ruby/system/System.hh"
#include "mem/ruby/eventqueue/RubyEventQueue.hh"
#include "mem/ruby/system/MemoryVector.hh"
#include "mem/ruby/common/Address.hh"
#include "mem/ruby/recorder/Tracer.hh"

string RubyRequestType_to_string(const RubyRequestType& obj)
{
  switch(obj) {
  case RubyRequestType_IFETCH:
    return "IFETCH";
  case RubyRequestType_LD:
    return "LD";
  case RubyRequestType_ST:
    return "ST";
  case RubyRequestType_Locked_Read:
    return "Locked_Read";
  case RubyRequestType_Locked_Write:
    return "Locked_Write";
  case RubyRequestType_RMW_Read:
    return "RMW_Read";
  case RubyRequestType_RMW_Write:
    return "RMW_Write";
  case RubyRequestType_NULL:
  default:
    assert(0);
    return "";
  }
}

RubyRequestType string_to_RubyRequestType(std::string str)
{
  if (str == "IFETCH")
    return RubyRequestType_IFETCH;
  else if (str == "LD")
    return RubyRequestType_LD;
  else if (str == "ST")
    return RubyRequestType_ST;
  else if (str == "Locked_Read")
    return RubyRequestType_Locked_Read;
  else if (str == "Locked_Write")
    return RubyRequestType_Locked_Write;
  else if (str == "RMW_Read")
    return RubyRequestType_RMW_Read;
  else if (str == "RMW_Write")
    return RubyRequestType_RMW_Write;
  else
    assert(0);
  return RubyRequestType_NULL;
}

ostream& operator<<(ostream& out, const RubyRequestType& obj)
{
  out << RubyRequestType_to_string(obj);
  out << flush;
  return out;
}

ostream& operator<<(std::ostream& out, const RubyRequest& obj)
{
  out << hex << "0x" << obj.paddr << " data: 0x" << flush;
  for (int i = 0; i < obj.len; i++) {
    out << (int)obj.data[i];
  }
  out << dec << " type: " << RubyRequestType_to_string(obj.type) << endl;
  return out;
}

vector<string> tokenizeString(string str, string delims)
{
  vector<string> tokens;
  char* pch;
  char* tmp;
  const char* c_delims = delims.c_str();
  tmp = new char[str.length()+1];
  strcpy(tmp, str.c_str());
  pch = strtok(tmp, c_delims);
  while (pch != NULL) {
    string tmp_str(pch);
    if (tmp_str == "null") tmp_str = "";
    tokens.push_back(tmp_str);

    pch = strtok(NULL, c_delims);
  }
  delete [] tmp;
{'fraction_non_alphanumeric': 0.13301035014314028, 'fraction_numerical': 0.002202158114952654, 'mean_word_length': 4.324736225087925, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '777621', 'n_tokens_mistral': 1691, 'n_tokens_neox': 1667, 'n_words': 361}