Fix visual jmp keys reset and malloc:// write error
This commit is contained in:
parent
49bbd39639
commit
3406d5eb52
|
@ -678,6 +678,7 @@ eprintf ("XXX: This command conflicts with 'ar'\n");
|
|||
r_cons_printf (
|
||||
"Usage: ag[?f]\n"
|
||||
" ag [addr] ; Output graphviz code (bb at addr and children)\n"
|
||||
" agj [addr] ; Idem, but in JSON format\n"
|
||||
" aga [addr] ; Idem, but only addresses\n"
|
||||
" agc [addr] ; Output graphviz call graph of function\n"
|
||||
" agd [fcn name] ; Output graphviz code of diffed function\n"
|
||||
|
|
|
@ -357,8 +357,10 @@ toro:
|
|||
addr, buf, len, -1, linesout, 1);
|
||||
} else core->reflines = core->reflines2 = NULL;
|
||||
|
||||
for (i=0; i<10; i++)
|
||||
core->asmqjmps[counter] = 0LL;
|
||||
/* reset jmp table if not a bad block */
|
||||
if (buf[0] != 0xff) // hack
|
||||
for (i=0; i<10; i++)
|
||||
core->asmqjmps[counter] = UT64_MAX;
|
||||
|
||||
oplen = 1;
|
||||
for (i=idx=ret=0; idx < len && lines < l; idx+=oplen,i++, lines++) {
|
||||
|
|
|
@ -228,14 +228,16 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
|
|||
// do we need hotkeys for data references? not only calls?
|
||||
if (ch>='0'&& ch<='9') {
|
||||
ut64 off = core->asmqjmps[ch-'0'];
|
||||
int delta = R_ABS (off-core->offset);
|
||||
r_io_sundo_push (core->io, core->offset);
|
||||
if (curset && delta<100) {
|
||||
cursor = delta;
|
||||
} else {
|
||||
r_core_seek (core, off, 1);
|
||||
if (off != UT64_MAX) {
|
||||
int delta = R_ABS (off-core->offset);
|
||||
r_io_sundo_push (core->io, core->offset);
|
||||
if (curset && delta<100) {
|
||||
cursor = delta;
|
||||
} else {
|
||||
r_core_seek (core, off, 1);
|
||||
}
|
||||
r_core_block_read (core, 1);
|
||||
}
|
||||
r_core_block_read (core, 1);
|
||||
} else
|
||||
switch (ch) {
|
||||
case 9: // tab
|
||||
|
|
|
@ -19,11 +19,15 @@ typedef struct {
|
|||
static int __write(RIO *io, RIODesc *fd, const ut8 *buf, int count) {
|
||||
if (fd == NULL || fd->data == NULL)
|
||||
return -1;
|
||||
if (io->off > RIOMALLOC_SZ (fd))
|
||||
return -1;
|
||||
if (io->off+count > RIOMALLOC_SZ (fd))
|
||||
count -= (io->off+count-(RIOMALLOC_SZ (fd)));
|
||||
if (count>0)
|
||||
if (count>0) {
|
||||
memcpy (RIOMALLOC_BUF (fd)+io->off, buf, count);
|
||||
return count;
|
||||
return count;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int __read(RIO *io, RIODesc *fd, ut8 *buf, int count) {
|
||||
|
|
|
@ -15,77 +15,7 @@ body {
|
|||
overflow:hidden;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.onresize = function () {
|
||||
resizeCanvas ();
|
||||
}
|
||||
|
||||
function resizeBlocks() {
|
||||
}
|
||||
|
||||
function Ajax (method, uri, body, fn) {
|
||||
var x = new XMLHttpRequest ();
|
||||
x.open (method, uri, false);
|
||||
x.onreadystatechange = function (y) {
|
||||
if (x.status == 200) {
|
||||
if (fn) fn (x.responseText);
|
||||
}
|
||||
}
|
||||
x.send (body);
|
||||
}
|
||||
|
||||
function get_graph() {
|
||||
Ajax ('GET', "/cmd/ag $$", '', function (x) {
|
||||
document.getElementById ('mainCanvas').innerHTML = x;
|
||||
setMenu ();
|
||||
resizeCanvas ();
|
||||
initPageObjects ();
|
||||
});
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
get_graph ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the main canvas to the maximum visible height.
|
||||
*/
|
||||
function resizeCanvas() {
|
||||
var divElement = document.getElementById("mainCanvas");
|
||||
var screenHeight = window.innerHeight || document.body.offsetHeight;
|
||||
divElement.style.height = (screenHeight - 16) + "px";
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the active menu scanning for a menu item which url is a prefix
|
||||
* of the one of the current page ignoring file extension.
|
||||
* Nice trick!
|
||||
*/
|
||||
function setMenu() {
|
||||
var url = document.location.href;
|
||||
// strip extension
|
||||
url = stripExtension(url);
|
||||
|
||||
var ulElement = document.getElementById("menu");
|
||||
var links = ulElement.getElementsByTagName("A");
|
||||
var i;
|
||||
for(i = 0; i < links.length; i++) {
|
||||
if(url.indexOf(stripExtension(links[i].href)) == 0) {
|
||||
links[i].className = "active_menu";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips the file extension and everything after from a url
|
||||
*/
|
||||
function stripExtension(url) {
|
||||
var lastDotPos = url.lastIndexOf('.');
|
||||
return (lastDotPos <= 0)? url:
|
||||
url.substring (0, lastDotPos - 1);
|
||||
}
|
||||
</script>
|
||||
<script src="index.js"> </script>
|
||||
</head>
|
||||
<body onload="onLoad();">
|
||||
<div id="menu"></div>
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
window.onresize = function () {
|
||||
resizeCanvas ();
|
||||
}
|
||||
|
||||
function resizeBlocks() {
|
||||
}
|
||||
|
||||
function Ajax (method, uri, body, fn) {
|
||||
var x = new XMLHttpRequest ();
|
||||
x.open (method, uri, false);
|
||||
x.onreadystatechange = function (y) {
|
||||
if (x.status == 200) {
|
||||
if (fn) fn (x.responseText);
|
||||
}
|
||||
}
|
||||
x.send (body);
|
||||
}
|
||||
|
||||
function get_graph() {
|
||||
Ajax ('GET', "/cmd/ag $$", '', function (x) {
|
||||
document.getElementById ('mainCanvas').innerHTML = x;
|
||||
setMenu ();
|
||||
resizeCanvas ();
|
||||
initPageObjects ();
|
||||
});
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
get_graph ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the main canvas to the maximum visible height.
|
||||
*/
|
||||
function resizeCanvas() {
|
||||
var divElement = document.getElementById("mainCanvas");
|
||||
var screenHeight = window.innerHeight || document.body.offsetHeight;
|
||||
divElement.style.height = (screenHeight - 16) + "px";
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the active menu scanning for a menu item which url is a prefix
|
||||
* of the one of the current page ignoring file extension.
|
||||
* Nice trick!
|
||||
*/
|
||||
function setMenu() {
|
||||
var url = document.location.href;
|
||||
// strip extension
|
||||
url = stripExtension(url);
|
||||
|
||||
var ulElement = document.getElementById("menu");
|
||||
var links = ulElement.getElementsByTagName("A");
|
||||
var i;
|
||||
for(i = 0; i < links.length; i++) {
|
||||
if(url.indexOf(stripExtension(links[i].href)) == 0) {
|
||||
links[i].className = "active_menu";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips the file extension and everything after from a url
|
||||
*/
|
||||
function stripExtension(url) {
|
||||
var lastDotPos = url.lastIndexOf('.');
|
||||
return (lastDotPos <= 0)? url:
|
||||
url.substring (0, lastDotPos - 1);
|
||||
}
|
|
@ -343,24 +343,25 @@ function Canvas(htmlElement) {
|
|||
return output;
|
||||
}
|
||||
|
||||
this.alignBlocks = function()
|
||||
{
|
||||
this.alignBlocks = function() {
|
||||
var i;
|
||||
var roof = 0;
|
||||
// TODO: implement proper layout
|
||||
for (i = 0; i < this.blocks.length ; i++) {
|
||||
var b = this.blocks[i]; //.findBlock(blockId);
|
||||
b.onMove();
|
||||
b.htmlElement.style.top =roof;
|
||||
roof += b.htmlElement.style.height+20;
|
||||
// TODO: alert ("align "+b);
|
||||
}
|
||||
for(i = 0; i < this.connectors.length; i++) {
|
||||
for (i = 0; i < this.connectors.length; i++) {
|
||||
this.connectors[i].repaint();
|
||||
console.log( this.connectors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.fitBlocks = function()
|
||||
{
|
||||
var i;
|
||||
for (i = 0; i < this.blocks.length ; i++) {
|
||||
this.fitBlocks = function() {
|
||||
for (var i = 0; i < this.blocks.length ; i++) {
|
||||
var b = this.blocks[i]; //.findBlock(blockId);
|
||||
this.blocks[i].fit ();
|
||||
}
|
||||
|
@ -368,20 +369,14 @@ function Canvas(htmlElement) {
|
|||
/*
|
||||
* This function searches for a nested block with a given id
|
||||
*/
|
||||
this.findBlock = function(blockId)
|
||||
{
|
||||
this.findBlock = function(blockId) {
|
||||
var result;
|
||||
var i;
|
||||
for(i = 0; i < this.blocks.length && !result; i++)
|
||||
{
|
||||
for(var i = 0; i < this.blocks.length && !result; i++)
|
||||
result = this.blocks[i].findBlock(blockId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
this.toString = function() {
|
||||
return 'canvas: ' + this.id;
|
||||
}
|
||||
}
|
||||
|
@ -406,65 +401,50 @@ function Block(htmlElement, canvas)
|
|||
this.currentTop = calculateOffsetTop(this.htmlElement) - this.canvas.offsetTop;
|
||||
this.currentLeft = calculateOffsetLeft(this.htmlElement) - this.canvas.offsetLeft;
|
||||
|
||||
this.visit = function(element)
|
||||
{
|
||||
if(element == this.htmlElement)
|
||||
{
|
||||
this.visit = function(element) {
|
||||
if (element == this.htmlElement) {
|
||||
// exclude itself
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isBlock(element))
|
||||
{
|
||||
if (isBlock(element)) {
|
||||
var innerBlock = new Block(element, this.canvas);
|
||||
innerBlock.initBlock();
|
||||
this.blocks.push(innerBlock);
|
||||
this.moveListeners.push(innerBlock);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
this.initBlock = function()
|
||||
{
|
||||
this.initBlock = function() {
|
||||
// inspect block children to identify nested blocks
|
||||
|
||||
new DocumentScanner(this, true).scan(this.htmlElement);
|
||||
}
|
||||
|
||||
this.top = function()
|
||||
{
|
||||
this.top = function() {
|
||||
return this.currentTop;
|
||||
}
|
||||
|
||||
this.left = function()
|
||||
{
|
||||
this.left = function() {
|
||||
return this.currentLeft;
|
||||
}
|
||||
|
||||
this.width = function()
|
||||
{
|
||||
this.width = function() {
|
||||
return this.htmlElement.offsetWidth;
|
||||
}
|
||||
|
||||
this.height = function()
|
||||
{
|
||||
this.height = function() {
|
||||
return this.htmlElement.offsetHeight;
|
||||
}
|
||||
|
||||
/*
|
||||
* methods
|
||||
*/
|
||||
this.print = function()
|
||||
{
|
||||
this.print = function() {
|
||||
var output = 'block: ' + this.id;
|
||||
if(this.blocks.length > 0)
|
||||
{
|
||||
if (this.blocks.length > 0) {
|
||||
output += '<ul>';
|
||||
var i;
|
||||
for(i = 0; i < this.blocks.length; i++)
|
||||
{
|
||||
for(var i = 0; i < this.blocks.length; i++) {
|
||||
output += '<li>';
|
||||
output += this.blocks[i].print();
|
||||
output += '</li>';
|
||||
|
@ -477,23 +457,16 @@ function Block(htmlElement, canvas)
|
|||
/*
|
||||
* This function searches for a nested block (or the block itself) with a given id
|
||||
*/
|
||||
this.findBlock = function(blockId)
|
||||
{
|
||||
this.findBlock = function(blockId) {
|
||||
if(this.id == blockId)
|
||||
return this;
|
||||
|
||||
var result;
|
||||
var i;
|
||||
for(i = 0; i < this.blocks.length && !result; i++)
|
||||
{
|
||||
for(var i = 0; i < this.blocks.length && !result; i++)
|
||||
result = this.blocks[i].findBlock(blockId);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
this.fit = function()
|
||||
{
|
||||
this.fit = function() {
|
||||
function getlines(txt) {
|
||||
return (12*txt.split ("\n").length);
|
||||
}
|
||||
|
@ -512,27 +485,21 @@ function Block(htmlElement, canvas)
|
|||
this.htmlElement.style.height = getlines (text);
|
||||
}
|
||||
|
||||
this.move = function(left, top)
|
||||
{
|
||||
this.move = function(left, top) {
|
||||
this.htmlElement.style.left = left;
|
||||
this.htmlElement.style.top = top;
|
||||
this.onMove();
|
||||
}
|
||||
|
||||
this.onMove = function()
|
||||
{
|
||||
var i;
|
||||
this.onMove = function() {
|
||||
this.currentLeft = calculateOffsetLeft(this.htmlElement) - this.canvas.offsetLeft;
|
||||
this.currentTop = calculateOffsetTop(this.htmlElement) - this.canvas.offsetTop;
|
||||
// notify listeners
|
||||
for(i = 0; i < this.moveListeners.length; i++)
|
||||
{
|
||||
for(var i = 0; i < this.moveListeners.length; i++)
|
||||
this.moveListeners[i].onMove();
|
||||
}
|
||||
}
|
||||
|
||||
this.toString = function()
|
||||
{
|
||||
this.toString = function() {
|
||||
return 'block: ' + this.id;
|
||||
}
|
||||
}
|
||||
|
@ -869,14 +836,12 @@ function Connector(htmlElement, canvas)
|
|||
*/
|
||||
this.repaint = function() {
|
||||
// check strategies fitness and choose the best fitting one
|
||||
var i;
|
||||
var maxFitness = 0;
|
||||
var fitness;
|
||||
var s;
|
||||
|
||||
// check if any strategy is possible with preferredOrientation
|
||||
for(i = 0; i < strategies.length; i++)
|
||||
{
|
||||
for(var i = 0; i < strategies.length; i++) {
|
||||
this.clearSegments();
|
||||
|
||||
fitness = 0;
|
||||
|
@ -1345,8 +1310,7 @@ function HorizontalSStrategy(connector) {
|
|||
return Math.abs(2 * destinationLeft + destinationWidth - (2 * sourceLeft + sourceWidth)) - (sourceWidth + destinationWidth) > 4 * this.connector.minSegmentLength;
|
||||
}
|
||||
|
||||
this.paint = function()
|
||||
{
|
||||
this.paint = function() {
|
||||
this.startSegment = connector.createSegment();
|
||||
this.middleSegment = connector.createSegment();
|
||||
this.endSegment = connector.createSegment();
|
||||
|
@ -1641,13 +1605,11 @@ function HorizontalCStrategy(connector, startOrientation)
|
|||
|
||||
this.strategyName = "horizontal_c";
|
||||
|
||||
this.getMiddleSegment = function()
|
||||
{
|
||||
this.getMiddleSegment = function() {
|
||||
return this.middleSegment;
|
||||
}
|
||||
|
||||
this.isApplicable = function()
|
||||
{
|
||||
this.isApplicable = function() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1736,6 +1698,7 @@ function VerticalCStrategy(connector, startOrientation)
|
|||
}
|
||||
}
|
||||
|
||||
//strategies[0] = function(connector) {return new VerticalCStrategy(connector)};
|
||||
strategies[0] = function(connector) {return new VerticalSStrategy(connector)};
|
||||
strategies[1] = function(connector) {return new HorizontalSStrategy(connector)};
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue