Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5d830a59ed0f
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 206ed769dbc0
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 24, 2015

  1. Copy the full SHA
    fccd4d7 View commit details
  2. Copy the full SHA
    206ed76 View commit details
Showing with 37 additions and 11 deletions.
  1. +21 −6 vm/builtin/location.cpp
  2. +16 −5 vm/metrics.cpp
27 changes: 21 additions & 6 deletions vm/builtin/location.cpp
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
#include "builtin/variable_scope.hpp"
#include "call_frame.hpp"
#include "ontology.hpp"
#include "on_stack.hpp"

namespace rubinius {
void Location::init(STATE) {
@@ -82,11 +83,22 @@ namespace rubinius {
return loc;
}

Array* Location::from_call_stack(STATE, CallFrame* start_call_frame,
Array* Location::from_call_stack(STATE, CallFrame* call_frame,
bool include_vars, bool on_ip)
{
Array* bt = Array::create(state, 5);
CallFrame* call_frame = start_call_frame;
size_t count = 0;

CallFrame* c = call_frame;
while(c) {
if(c->compiled_code) count++;
c = c->previous;
}

Array* bt = 0;
Location* loc = 0;
OnStack<2> os(state, bt, loc);

bt = Array::create(state, count);

// Initial edge.
if(!call_frame) return bt;
@@ -98,7 +110,7 @@ namespace rubinius {
if(!call_frame) return bt;
}

Location* loc = Location::create(state, call_frame, include_vars);
loc = Location::create(state, call_frame, include_vars);
if(on_ip) loc->set_ip_on_current(state);

bt->append(state, loc);
@@ -110,7 +122,7 @@ namespace rubinius {
if(call_frame->compiled_code) {
bt->append(state, Location::create(state, call_frame, include_vars));
} else if(NativeMethodFrame* nmf = call_frame->native_method_frame()) {
Location* loc = Location::create(state, nmf);
loc = Location::create(state, nmf);
if(loc) bt->append(state, loc);
}

@@ -121,6 +133,9 @@ namespace rubinius {
}

Array* Location::mri_backtrace(STATE, CallFrame* call_frame) {
Array* bt = 0;
OnStack<1> os(state, bt);

size_t count = 0;

CallFrame* c = call_frame;
@@ -129,7 +144,7 @@ namespace rubinius {
c = c->previous;
}

Array* bt = Array::create(state, count);
bt = Array::create(state, count);

while(call_frame) {
// Ignore synthetic frames
21 changes: 16 additions & 5 deletions vm/metrics.cpp
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ namespace rubinius {
cleanup();
}

#define RBX_METRICS_FILE_BUFLEN 22
#define RBX_METRICS_FILE_BUFLEN 256

void FileEmitter::send_metrics() {
char buf[RBX_METRICS_FILE_BUFLEN];
@@ -93,7 +93,10 @@ namespace rubinius {
logger::error("%s: unable to write file metrics", strerror(errno));
}
}
write(fd_, "\n", 1);

if(write(fd_, "\n", 1)) {
logger::error("%s: unable to write file metrics", strerror(errno));
}
}

void FileEmitter::initialize() {
@@ -102,14 +105,22 @@ namespace rubinius {
}

if(lseek(fd_, 0, SEEK_END) == 0) {
char buf[RBX_METRICS_FILE_BUFLEN];

for(MetricsMap::iterator i = metrics_map_.begin();
i != metrics_map_.end();
++i)
{
if(i != metrics_map_.begin()) write(fd_, ", ", 2);
write(fd_, (*i)->first.c_str(), (*i)->first.size());
snprintf(buf, RBX_METRICS_FILE_BUFLEN, "%s%s",
i == metrics_map_.begin() ? "" : ", ", (*i)->first.c_str());
if(write(fd_, buf, strlen(buf)) < 0) {
logger::error("%s: unable to write file metrics", strerror(errno));
}
}

if(write(fd_, "\n", 1)) {
logger::error("%s: unable to write file metrics", strerror(errno));
}
write(fd_, "\n", 1);
}
}