Example #1
0
// Called by fatal error handler.
void VM_Operation::print_on_error(outputStream* st) const {
  st->print("VM_Operation (" PTR_FORMAT "): ", p2i(this));
  st->print("%s", name());

  const char* mode = mode_to_string(evaluation_mode());
  st->print(", mode: %s", mode);

  if (calling_thread()) {
    st->print(", requested by thread " PTR_FORMAT, p2i(calling_thread()));
  }
}
Example #2
0
static void set_dllmode(HWND dialog, DWORD id)
{
    enum dllmode mode;
    struct dll *dll;
    int sel;
    const char *str;

    mode = id_to_mode(id);

    sel = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCURSEL, 0, 0);
    if (sel == -1) return;

    dll = (struct dll *) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, sel, 0);

    str = mode_to_string(mode);
    WINE_TRACE("Setting %s to %s\n", dll->name, str);

    SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
    set_reg_key(config_key, keypath("DllOverrides"), dll->name, str);

    load_library_settings(dialog);  /* ... and refresh  */
}
static int __init setup_watchpoint(char *str)
{
	char *p;
	unsigned long va, width;
	int mode;

	va = simple_strtoul(str, &p, 0);
	if (p == str) {
		pr_err("Unknown 'watch=' numeric value: %s\n", str);
		return -EINVAL;
	}
	str = p;
	if (*str == '/') {
		++str;
		width = simple_strtoul(str, &p, 0);
		if (p == str) {
			pr_err("Unknown 'watch=' width qualifier: %s\n", str);
			return -EINVAL;
		}
		if (__builtin_popcount(width) != 1) {
			pr_err("'watch=' width value not power of two: %ld\n",
			       width);
			return -EINVAL;
		}
		str = p;
	} else {
		width = 1;
	}
	if (*str == ',') {
		mode = string_to_mode(++str);
		if (mode == -1) {
			pr_err("Unknown 'watch=' qualifier '%s'\n", str);
			return -EINVAL;
		}
	} else {
		mode = string_to_mode("default");
	}

	/* FIXME: we only need to reserve PERF_COUNT_0. */
	if (reserve_pmc_hardware(handle_watch_interrupt))
		return -EINVAL;

	pr_notice("Watching VAs %#lx..%#lx,%s\n",
		  va, va + width - 1, mode_to_string(mode));

	__insn_mtspr(SPR_WATCH_VAL, va);

#ifdef __tilegx__
	/* Watch only the VA bits, not the high bits. */
	__insn_mtspr(SPR_WATCH_MASK, (-1ULL << 42) | (width - 1));

	/*
	 * We assume SPR_DIAG_MUX_CTL is set for Mbox output in the hv.
	 * Select "special" for perf counter zero, using "watch SPR" output.
	 */
	__insn_mtspr(SPR_PERF_COUNT_CTL, (7 << 6) | 0);
#else
	/* Watch requested VA bits. */
	__insn_mtspr(SPR_WATCH_MASK, width - 1);
	/* Choose watching the appropriate type of access. */
	__insn_mtspr(SPR_WATCH_CTL, mode);
	/* Select DIAG_SPCL_EVENT_WATCH for performance counter 0. */
	__insn_mtspr(SPR_PERF_COUNT_CTL, 106);
#endif

	__insn_mtspr(SPR_PERF_COUNT_0, -1);
	unmask_pmc_interrupts();

	return 0;
}
Example #4
0
int main( int ac, char** av )
{
    try
    {
        comma::command_line_options options( ac, av, usage );
        comma::csv::options input_csv( options, field_names< snark::control::target_t >() );
        const char delimiter = input_csv.delimiter;
        comma::csv::input_stream< snark::control::target_t > input_stream( std::cin, input_csv, snark::control::target_t( options.exists( "--heading-is-absolute" ) ) );
        comma::csv::options output_csv( options );
        output_csv.full_xpath = true;
        output_csv.fields = "wayline/heading,error/cross_track,error/heading";
        if( input_csv.binary() ) { output_csv.format( format< snark::control::control_data_t >( output_csv.fields, true ) ); }
        comma::csv::output_stream< snark::control::control_data_t > output_stream( std::cout, output_csv );
        if( options.exists( "--format" ) ) { std::cout << format< snark::control::target_t >() << std::endl; return 0; }
        if( options.exists( "--output-format" ) ) { std::cout << format< snark::control::control_data_t >( output_csv.fields, true ) << std::endl; return 0; }
        if( options.exists( "--output-fields" ) ) { std::cout << output_csv.fields << std::endl; return 0; }
        double proximity = options.value< double >( "--proximity", default_proximity );
        if( proximity <= 0 ) { std::cerr << name << ": expected positive proximity, got " << proximity << std::endl; return 1; }
        control_mode_t mode = mode_from_string( options.value< std::string >( "--mode", default_mode ) );
        bool use_past_endpoint = options.exists( "--past-endpoint" );
        bool use_delay = options.exists( "--frequency,-f" );
        boost::posix_time::microseconds delay( 0 );
        boost::posix_time::ptime next_output_time( boost::posix_time::microsec_clock::universal_time() );
        if( use_delay )
        {
            double frequency = options.value< double >( "--frequency,-f" );
            if( frequency <= 0 ) { std::cerr << name << ": expected positive frequency, got " << frequency << std::endl; return 1; }
            delay = boost::posix_time::microseconds( static_cast< long >( 1000000 / frequency ) );
        }
        bool verbose = options.exists( "--verbose,-v" );
        std::vector< std::string > unnamed = options.unnamed( "--help,-h,--verbose,-v,--format,--output-format,--output-fields,--past-endpoint,--heading-is-absolute", "-.*,--.*" );
        if( unnamed.empty() ) { std::cerr << name << ": feedback stream is not given" << std::endl; return 1; }
        comma::csv::options feedback_csv = comma::name_value::parser( "filename", ';', '=', false ).get< comma::csv::options >( unnamed[0] );
        if( input_csv.binary() && !feedback_csv.binary() ) { std::cerr << name << ": cannot join binary input stream with ascii feedback stream" << std::endl; return 1; }
        if( !input_csv.binary() && feedback_csv.binary() ) { std::cerr << name << ": cannot join ascii input stream with binary feedback stream" << std::endl; return 1; }
        if( feedback_csv.fields.empty() ) { feedback_csv.fields = field_names< snark::control::feedback_t >(); }
        comma::io::istream feedback_in( feedback_csv.filename, feedback_csv.binary() ? comma::io::mode::binary : comma::io::mode::ascii, comma::io::mode::non_blocking );
        comma::csv::input_stream< snark::control::feedback_t > feedback_stream( *feedback_in, feedback_csv );
        comma::io::select select;
        select.read().add( feedback_in );
        boost::optional< snark::control::vector_t > from;
        boost::scoped_ptr< snark::control::wayline_t > wayline;
        comma::signal_flag is_shutdown;
        while( !is_shutdown && ( input_stream.ready() || ( std::cin.good() && !std::cin.eof() ) ) )
        {
            reached_t reached;
            const snark::control::target_t* target = input_stream.read();
            if( !target ) { break; }
            snark::control::vector_t to = target->position;
            if( verbose ) { std::cerr << name << ": received target waypoint " << snark::control::serialise( to ) << std::endl; }
            if( from && snark::control::distance( *from, to ) < proximity ) { continue; }
            if( from ) { wayline.reset( new snark::control::wayline_t( *from, to, verbose ) ); }
            while( !is_shutdown && std::cout.good() )
            {
                if( input_stream.ready() )
                {
                    if( mode == fixed ) {}
                    else if( mode == dynamic ) { from = boost::none; break; }
                    else { std::cerr << name << ": control mode '" << mode_to_string( mode ) << "' is not implemented" << std::endl; return 1; }
                }
                select.wait( boost::posix_time::microseconds( 10000 ) );
                if( !is_shutdown && ( feedback_stream.ready() || select.read().ready( feedback_in ) ) )
                {
                    const snark::control::feedback_t* feedback = feedback_stream.read();
                    if( !feedback ) { std::cerr << name << ": feedback stream error occurred prior to reaching waypoint " << snark::control::serialise( to ) << std::endl; return 1; }
                    if( use_delay && boost::posix_time::microsec_clock::universal_time() < next_output_time ) { continue; }
                    if( !from )
                    {
                        from = feedback->position;
                        wayline.reset( new snark::control::wayline_t( *from, to, verbose ) );
                    }
                    if( snark::control::distance( feedback->position, to ) < proximity ) { reached = reached_t( "proximity" ); }
                    if( use_past_endpoint && wayline->is_past_endpoint( feedback->position ) ) { reached = reached_t( "past endpoint" ); }
                    if( reached )
                    {
                        if( verbose ) { std::cerr << name << ": waypoint " << snark::control::serialise( to ) << " is reached (" << reached.reason << ")" << std::endl; }
                        if( mode == fixed ) { from = to; }
                        else if( mode == dynamic ) { from = boost::none; }
                        else { std::cerr << name << ": control mode '" << mode_to_string( mode ) << "' is not implemented" << std::endl; return 1; }
                        break;
                    }
                    snark::control::error_t error;
                    error.cross_track = wayline->cross_track_error( feedback->position );
                    if( target->is_absolute ) { error.heading = snark::control::wrap_angle( target->heading_offset - feedback->yaw ); }
                    else { error.heading = wayline->heading_error( feedback->yaw, target->heading_offset ); }
                    if( input_csv.binary() ) { std::cout.write( input_stream.binary().last(), input_csv.format().size() ); }
                    else { std::cout << comma::join( input_stream.ascii().last(), delimiter ) << delimiter; }
                    if( feedback_csv.binary() ) { std::cout.write( feedback_stream.binary().last(), feedback_csv.format().size() ); }
                    else { std::cout << comma::join( feedback_stream.ascii().last(), delimiter ) << delimiter; }
                    output_stream.write( snark::control::control_data_t( *wayline, error ) );
                    if( use_delay ) { next_output_time = boost::posix_time::microsec_clock::universal_time() + delay; }
                }
            }
        }
        return 0;
    }
    catch( std::exception& ex ) { std::cerr << name << ": " << ex.what() << std::endl; }
    catch( ... ) { std::cerr << name << ": unknown exception" << std::endl; }
    return 1;
}