Skip to content

Instantly share code, notes, and snippets.

Yury Delendik yurydelendik

Block or report user

Report or block yurydelendik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yurydelendik
yurydelendik / !wasmllvm.md
Last active Oct 17, 2019
Using WebAssembly in LLVM
View !wasmllvm.md

NOTE: the content is out-of-date. All development is moved to the https://github.com/yurydelendik/wasmception

Using WebAssembly in LLVM

Compiling

# locations, e.g.
export WORKDIR=~/llvmwasm; mkdir -p $WORKDIR
export INSTALLDIR=$WORKDIR
View hello2.expanded.rs
#![feature(prelude_import)]
#![no_std]
#![doc = " Translation of hello example"]
#[prelude_import]
use ::std::prelude::v1::*;
#[macro_use]
extern crate std as std;
use failure::{bail, format_err, Error};
use std::cell::Ref;
use std::fs::read;
@yurydelendik
yurydelendik / gist:f2b846dae7cb29c86d23
Last active Aug 11, 2019
PDF.js get/show hightlight
View gist:f2b846dae7cb29c86d23
function getHightlightCoords() {
var pageIndex = PDFViewerApplication.pdfViewer.currentPageNumber - 1;
var page = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
var pageRect = page.canvas.getClientRects()[0];
var selectionRects = window.getSelection().getRangeAt(0).getClientRects();
var viewport = page.viewport;
var selected = selectionRects.map(function (r) {
return viewport.convertToPdfPoint(r.left - pageRect.x, r.top - pageRect.y).concat(
viewport.convertToPdfPoint(r.right - pageRect.x, r.bottom - pageRect.y));
});
View node-wasi-sassc.patch
diff --git a/run.js b/run.js
index 87928f1..94f353d 100755
--- a/run.js
+++ b/run.js
@@ -30,9 +30,11 @@ USAGE:
const bin = fs.readFileSync(process.argv[2]);
const mod = new WebAssembly.Module(bin);
+const preopenDirectories = {};
+preopenDirectories[process.cwd()] = process.cwd();
@yurydelendik
yurydelendik / lldb-jit-unwind.diff
Created Feb 12, 2019
Trust JIT unwind plan patch for lldb
View lldb-jit-unwind.diff
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 423b2e53c66..62dedbd75a6 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -829,6 +829,22 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
}
}
+ // The JIT generated module may generate their .eh_frame or .debug_frame
+ // sections. It makes sense to trust that unwind plan if it is valid.
@yurydelendik
yurydelendik / .htaccess
Last active Feb 5, 2019
CORS for pdf.js
View .htaccess
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "http://mozilla.github.io"
</IfModule>
@yurydelendik
yurydelendik / sourceURLPrefixes.md
Created Aug 29, 2018
sourceURLPrefixes WebAssembly custom section
View sourceURLPrefixes.md

sourceURLPrefixes WebAssembly custom section

This custom section is created to provide mapping of the local (or remote) file paths to network resources. Currently we can have DWARF sections inside the binary WebAssembly file, however debugger, in most of the cases, cannot retrive local files -- this file paths needs to be mapped to some networks server location.

Format

The custom section has the following format:

@yurydelendik
yurydelendik / x-scopes.md
Created Aug 1, 2018
Experimental "x-scopes" source maps extension
View x-scopes.md

Experimental "x-scopes" source maps extension

This is crude attempt to add DWARF-like information to the existing wasm source maps. It is not intendent to be used as a final solution, but provides overview of the information that can be used by a consumer/debugger of wasm code.

The source maps JSON is extended to add the x-scopes field at the top level that will contains all information generated by LLVM's llvm-dwarfdump command. To reduce burden of parsing at the consumer side, the dump will be converted to the JSON using following rules:

  1. DW_TAG_xxx entity will be converted to a JS object with tag field with xxx value.
  2. If the above entry has nested level of children, the children field will be added and will contain JS array.
  3. DW_AT_yyy attributes will be assigned at fields to the enclosing object with yyy name. Theirs values will be:
@yurydelendik
yurydelendik / dbg_value.diff
Last active Jan 20, 2019
Attept to extend DBG_VALUE functionality
View dbg_value.diff
Index: include/llvm/BinaryFormat/Dwarf.def
===================================================================
diff --git a/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def b/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def
--- a/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def (revision 336356)
+++ b/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def (working copy)
@@ -617,6 +617,8 @@
// Vendor extensions:
// Extensions for GNU-style thread-local storage.
HANDLE_DW_OP(0xe0, GNU_push_tls_address, 0, GNU)
+// Extensions for WebAssembly.
@yurydelendik
yurydelendik / README.md
Last active Jan 12, 2019
Build wasm maps from C++ file
View README.md
You can’t perform that action at this time.