Skip to content

Instantly share code, notes, and snippets.

@Geal
Geal / dog.rs
Created February 13, 2019 17:35
//extern crate conform;
extern crate flate2;
extern crate image;
extern crate ndarray;
extern crate tar;
extern crate protobuf;
#[allow(unused_imports)]
#[macro_use]
extern crate tract_core;
$ RUST_BACKTRACE=1 cargo run --bin wasmtime -- testload.wasm --function=load
Finished dev [unoptimized + debuginfo] target(s) in 0.21s
Running `target/debug/wasmtime testload.wasm --function=load`
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:355:21
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
box:wasmtime geal$ lldb ./target/debug/wasmtime
(lldb) target create "./target/debug/wasmtime"
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Current executable set to './target/debug/wasmtime' (x86_64).
#[derive(Clone, Debug, PartialEq)]
pub enum State {
Start(Start),
End(End),
Error(Error),
}
#[derive(Clone, Debug, PartialEq)]
pub struct Start {
pub x: u8,
}
time: 0.034 lint checking
time: 0.002 resolving dependency formats
time: 0.000 write metadata
time: 0.002 collecting roots
time: 16.834 collecting mono items
time: 16.836 monomorphization collection
time: 0.031 codegen unit partitioning
time: 0.000 write allocator module
time: 0.000 llvm function passes [2mhp9uvb4kzbepub]
time: 0.003 llvm module passes [2mhp9uvb4kzbepub]
[applications]
[applications.MyApp]
protocol = "http"
frontends = [
{ address = "0.0.0.0:8080", hostname = "lolcatho.st" },
{ address = "0.0.0.0:8443", hostname = "lolcatho.st", certificate = "./certificate.pem", key = "./key.pem", certificate_chain = "./certificate_chain.pem" }
]
backends = [
2018-06-11T10:45:23Z 93702249952884119 15494 MASTER INFO Starting up
2018-06-11T10:45:23Z 93702249954455053 15494 MASTER INFO 0 launching worker
2018-06-11T10:45:23Z 93702249954929654 15494 MASTER INFO 0 worker launched: 15495
2018-06-11T10:45:23Z 93702249956332870 15494 MASTER INFO sent listeners from master: Ok(())
2018-06-11T10:45:23Z 93702249956388348 15494 MASTER INFO created workers: [Worker { id: 0, run_state: Running }]
2018-06-11T10:45:23Z 93702249956441773 15494 MASTER ERROR could not get saved state path: No such file or directory (os error 2)
2018-06-11T10:45:23Z 93702249956598017 15494 MASTER ERROR could not register metrics socket
2018-06-11T10:45:23Z 93702249960080091 15495 WRK-00 INFO worker 0 starting...
2018-06-11T10:45:23Z 93702249975576411 15494 MASTER INFO waiting for configuration client connections
2018-06-11T10:45:25Z 93702252398634451 15495 WRK-00 INFO will try to receive listeners

fonctionnement de la stack

Les appels entre fonction sont supportés au niveau du processeur par l'utilisation de la pile (ou "stack"), une structure de donnée supportant les instructions "push" et "pop". C'est une structure "LIFO" (last in, first out): le dernier élément placé sur la pile (push) est le premier élément qu'on peut en retirer (pop).

Lorsque le processeur exécute du code, l'un de ses registres (EIP sur les processeurs X86 et X86_64) contient toujours l'adresse de l'instruction courante. Lorsque le code exécuté appelle une fonction, c'est généralement équivalent à appeler une instruction JMP pour "jump" vers une nouvelle adresse:

pub struct NomIterator<I,O> {
input: Option<I>,
parser: Box<Fn(I) -> IResult<I,O> + 'static>,
}
impl<I,O> NomIterator<I,O> {
fn new(input: I, parser: Box<Fn(I) -> IResult<I,O> + 'static>) -> NomIterator<I,O> {
NomIterator {
input: Some(input),
@Geal
Geal / ClientSocket.cpp
Last active June 21, 2019 21:01
TP multithreading EPSI 4 2018 28/03/2018
#include "ClientSocket.h"
#include "SocketException.h"
ClientSocket::ClientSocket ( std::string host, int port ){
if ( ! Socket::create() ){
throw SocketException ( "Could not create client socket." );
}
if ( ! Socket::connect ( host, port ) ) {