Esempio n. 1
0
/*
dumps the current execution stack. usage: dump_bt executor_globals.current_execute_data
define dump_bt
        set $t = $arg0
        while $t
                printf "[0x%08x] ", $t
                if $t->function_state.function->common.function_name
                        printf "%s() ", $t->function_state.function->common.function_name
                else
                        printf "??? "
                end
                if $t->op_array != 0
                        printf "%s:%d ", $t->op_array->filename, $t->opline->lineno
                end
                set $t = $t->prev_execute_data
                printf "\n"
        end
end
*/
void print_php_trace()
{
	struct _zend_execute_data *ed = executor_globals.current_execute_data;
	fprintf(stderr, "PHP backtrace:\n");
	while(ed && safe_pointer(ed))  {
		zend_function *func = ed->function_state.function;
		char *funcname, *filename;
		zend_op_array *op_array = ed->op_array;
		struct _zend_op *opline = ed->opline;
		int lineno = 0;
		
		if(safe_pointer(func)) {
			funcname = func->common.function_name;
		} else {
			funcname = "[???]";
		}
		if(safe_pointer(op_array)) {
			filename = op_array->filename;
		} else {
			filename = "[???]";
		}
		if(safe_pointer(opline)) {
			lineno = opline->lineno;
		} 
		fprintf(stderr, "%s() %s:%d\n", safe_string(funcname), safe_string(filename), lineno);
		ed = ed->prev_execute_data;
	}
}
Esempio n. 2
0
static void
on_songio_status_changed (BtSongIO * songio, GParamSpec * arg,
    gpointer user_data)
{
  BtEditApplication *self = BT_EDIT_APPLICATION (user_data);
  gchar *str;

  /* IDEA(ensonic): bind properties */
  g_object_get (songio, "status", &str, NULL);
  GST_INFO ("songio_status has changed : \"%s\"", safe_string (str));
  bt_child_proxy_set (self->priv->main_window, "statusbar::status", str, NULL);
  g_free (str);
}
Esempio n. 3
0
    bool command_manager::run_command(const safe_string& cmd, const safe_vector<safe_string>& args, /*out*/ safe_string& output)
    {
        command* h = nullptr;
        {
            utils::auto_read_lock l(_lock);
            auto it = _handlers.find(cmd);
            if (it != _handlers.end())
                h = it->second;
        }

        if (h == nullptr)
        {
            output = safe_string("unknown command '") + cmd + "'";
            return false;
        }
        else
        {
            if (h->address.is_invalid() || h->address == dsn::task::get_current_rpc()->primary_address())
            {
                output = h->handler(args);
                return true;
            }
            else
            {
                ::dsn::rpc_read_stream response;
                
                dsn_message_t msg = dsn_msg_create_request(RPC_CLI_CLI_CALL);
                ::dsn::command rcmd;
                rcmd.cmd = cmd.c_str();
                for (auto& e : args)
                {
                    rcmd.arguments.emplace_back(e.c_str());
                }

                ::dsn::marshall(msg, rcmd);
                auto resp = dsn_rpc_call_wait(h->address.c_addr(), msg);
                if (resp != nullptr)
                {
                    std::string o2 = output.c_str();
                    ::dsn::unmarshall(resp, o2);
                    return true;
                }
                else
                {
                    dwarn("cli run for %s is too long, timeout", cmd.c_str());
                    return false;
                }
            }
        }
    }
Esempio n. 4
0
File: names.c Progetto: njb5174/Hake
void list_names_print(const struct list_names * const list)
{
  verify(list != NULL, "null arg list");

  printf("list of names: %s\n", safe_string(list->name));

  if (list->head == NULL)
    { printf("  <empty>\n"); }
  else
    {
      for (struct name *p = list->head; p != NULL; p = p->next)
	{ printf("  %s\n", p->name); }
    }
}
Esempio n. 5
0
static void
on_name_notify (const BtSongInfo * song_info, GParamSpec * arg,
    gpointer user_data)
{
  BtMainPageInfo *self = BT_MAIN_PAGE_INFO (user_data);
  gchar *name;

  g_object_get ((gpointer) song_info, "name", &name, NULL);
  g_signal_handlers_block_matched (self->priv->name,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_name_changed,
      (gpointer) self);
  gtk_entry_set_text (self->priv->name, safe_string (name));
  g_free (name);
  g_signal_handlers_unblock_matched (self->priv->name,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_name_changed,
      (gpointer) self);
}
Esempio n. 6
0
static void
on_song_changed (const BtEditApplication * app, GParamSpec * arg,
    gpointer user_data)
{
  BtMainPageInfo *self = BT_MAIN_PAGE_INFO (user_data);
  BtSong *song;
  GtkTextBuffer *buffer;
  gchar *name, *genre, *author, *create_dts, *change_dts;
  gulong bpm, tpb, bars;
  gchar *info;

  GST_INFO ("song has changed : app=%p, self=%p", app, self);
  g_object_try_unref (self->priv->song_info);

  // get song from app
  g_object_get (self->priv->app, "song", &song, NULL);
  if (!song) {
    self->priv->song_info = NULL;
    return;
  }
  GST_INFO ("song: %" G_OBJECT_REF_COUNT_FMT, G_OBJECT_LOG_REF_COUNT (song));

  g_object_get (song, "song-info", &self->priv->song_info, NULL);
  // update info fields
  g_object_get (self->priv->song_info,
      "name", &name, "genre", &genre, "author", &author, "info", &info,
      "bpm", &bpm, "tpb", &tpb, "bars", &bars,
      "create-dts", &create_dts, "change-dts", &change_dts, NULL);
  g_signal_handlers_block_matched (self->priv->name,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_name_changed,
      (gpointer) self);
  gtk_entry_set_text (self->priv->name, safe_string (name));
  g_free (name);
  g_signal_handlers_unblock_matched (self->priv->name,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_name_changed,
      (gpointer) self);

  g_signal_handlers_block_matched (self->priv->genre,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_genre_changed,
      (gpointer) self);
  gtk_entry_set_text (self->priv->genre, safe_string (genre));
  g_free (genre);
  g_signal_handlers_unblock_matched (self->priv->genre,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_genre_changed,
      (gpointer) self);

  g_signal_handlers_block_matched (self->priv->author,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_author_changed,
      (gpointer) self);
  gtk_entry_set_text (self->priv->author, safe_string (author));
  g_free (author);
  g_signal_handlers_unblock_matched (self->priv->author,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_author_changed,
      (gpointer) self);

  g_signal_handlers_block_matched (self->priv->bpm,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_bpm_changed,
      (gpointer) self);
  gtk_spin_button_set_value (self->priv->bpm, (gdouble) bpm);
  g_signal_handlers_unblock_matched (self->priv->bpm,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_bpm_changed,
      (gpointer) self);

  g_signal_handlers_block_matched (self->priv->tpb,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_tpb_changed,
      (gpointer) self);
  gtk_spin_button_set_value (self->priv->tpb, (gdouble) tpb);
  g_signal_handlers_unblock_matched (self->priv->tpb,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_tpb_changed,
      (gpointer) self);

  g_signal_handlers_block_matched (self->priv->beats,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_beats_changed,
      (gpointer) self);
  gtk_spin_button_set_value (self->priv->beats, (gdouble) (bars / tpb));
  g_signal_handlers_unblock_matched (self->priv->beats,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_beats_changed,
      (gpointer) self);

  /* the iso date is not nice for the user
   * struct tm tm;
   * char dts[255];
   *
   * strptime(create_dts, "%FT%TZ", &tm);
   * strftime(dts, sizeof(buf), "%F %T", &tm);
   *
   * but the code below is simpler and works too :)
   */
  create_dts[10] = ' ';
  create_dts[19] = '\0';
  gtk_entry_set_text (self->priv->date_created, create_dts);
  g_free (create_dts);
  change_dts[10] = ' ';
  change_dts[19] = '\0';
  gtk_entry_set_text (self->priv->date_changed, change_dts);
  g_free (change_dts);

  buffer = gtk_text_view_get_buffer (self->priv->info);
  g_signal_handlers_block_matched (buffer,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_info_changed,
      (gpointer) self);
  gtk_text_buffer_set_text (buffer, safe_string (info), -1);
  g_free (info);
  g_signal_handlers_unblock_matched (buffer,
      G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, on_info_changed,
      (gpointer) self);

  g_signal_connect (self->priv->song_info, "notify::name",
      G_CALLBACK (on_name_notify), (gpointer) self);

  // release the references
  g_object_unref (song);
  GST_INFO ("song has changed done");
}
Esempio n. 7
0
gint
main (gint argc, gchar ** argv)
{
  gboolean res = FALSE;
  gboolean arg_version = FALSE;
  gboolean arg_quiet = FALSE;
  gchar *command = NULL, *input_file_name = NULL, *output_file_name = NULL;
  gint saved_argc = argc;
  BtCmdApplication *app;
  GOptionContext *ctx;
  GOptionGroup *group;
  GError *err = NULL;

#ifdef ENABLE_NLS
  setlocale (LC_ALL, "");
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

  static GOptionEntry options[] = {
    {"version", '\0', 0, G_OPTION_ARG_NONE, NULL,
        N_("Print application version"), NULL},
    {"quiet", 'q', 0, G_OPTION_ARG_NONE, NULL, N_("Be quiet"), NULL},
    {"command", 'c', 0, G_OPTION_ARG_STRING, NULL, N_("Command name"),
        "{info, play, convert, encode}"},
    {"input-file", 'i', 0, G_OPTION_ARG_FILENAME, NULL, N_("Input file name"),
        N_("<songfile>")},
    {"output-file", 'o', 0, G_OPTION_ARG_FILENAME, NULL, N_("Output file name"),
        N_("<songfile>")},
    {NULL}
  };
  // setting this separately gets us from 76 to 10 instructions
  options[0].arg_data = &arg_version;
  options[1].arg_data = &arg_quiet;
  options[2].arg_data = &command;
  options[3].arg_data = &input_file_name;
  options[4].arg_data = &output_file_name;

  // init libraries
  ctx = g_option_context_new (NULL);
  //g_option_context_add_main_entries(ctx, options, GETTEXT_PACKAGE);
  group =
      g_option_group_new ("main", _("buzztrax-cmd options"),
      _("Show buzztrax-cmd options"), argv[0], NULL);
  g_option_group_add_entries (group, options);
  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
  g_option_context_set_main_group (ctx, group);

  bt_init_add_option_groups (ctx);
  g_option_context_add_group (ctx, btic_init_get_option_group ());

  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", safe_string (err->message));
    g_option_context_free (ctx);
    exit (1);
  }
  if (arg_version) {
    g_printf ("%s from " PACKAGE_STRING "\n", argv[0]);
    res = TRUE;
    goto Done;
  }
  if (!command) {
    if (argc == saved_argc) {
      usage (argc, argv, ctx);
    }
    goto Done;
  }

  GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "bt-cmd", 0,
      "music production environment / command ui");
  GST_INFO ("starting: command=\"%s\" input=\"%s\" output=\"%s\"", command,
      input_file_name, output_file_name);

  // give some global context info
  g_set_prgname ("buzztrax-cmd");
  g_set_application_name ("Buzztrax");
  g_setenv ("PULSE_PROP_application.icon_name", "buzztrax", TRUE);
  g_setenv ("PULSE_PROP_media.role", "production", TRUE);

  app = bt_cmd_application_new (arg_quiet);


  // set a default command, if a file is given
  if (!command && BT_IS_STRING (input_file_name)) {
    command = g_strdup ("p");
  }
  // depending on the options call the correct method
  if (!strcmp (command, "p") || !strcmp (command, "play")) {
    if (!BT_IS_STRING (input_file_name))
      usage (argc, argv, ctx);
    res = bt_cmd_application_play (app, input_file_name);
  } else if (!strcmp (command, "i") || !strcmp (command, "info")) {
    if (!BT_IS_STRING (input_file_name))
      usage (argc, argv, ctx);
    res = bt_cmd_application_info (app, input_file_name, output_file_name);
  } else if (!strcmp (command, "c") || !strcmp (command, "convert")) {
    if (!BT_IS_STRING (input_file_name) || !BT_IS_STRING (output_file_name))
      usage (argc, argv, ctx);
    res = bt_cmd_application_convert (app, input_file_name, output_file_name);
  } else if (!strcmp (command, "e") || !strcmp (command, "encode")) {
    if (!BT_IS_STRING (input_file_name) || !BT_IS_STRING (output_file_name))
      usage (argc, argv, ctx);
    res = bt_cmd_application_encode (app, input_file_name, output_file_name);
  } else
    usage (argc, argv, ctx);

  // free application
  g_object_unref (app);

Done:
  g_free (command);
  g_free (input_file_name);
  g_free (output_file_name);
  g_option_context_free (ctx);

  return !res;
}
Esempio n. 8
0
/*
 * Pretty print single event.
 */
static void print_events(struct lttng_event *event)
{
	int ret;
	const char *filter_str;
	char *filter_msg = NULL;
	char *exclusion_msg = NULL;

	ret = lttng_event_get_filter_expression(event, &filter_str);

	if (ret) {
		filter_msg = strdup(" [failed to retrieve filter]");
	} else if (filter_str) {
		const char * const filter_fmt = " [filter: '%s']";

		filter_msg = malloc(strlen(filter_str) +
				strlen(filter_fmt) + 1);
		if (filter_msg) {
			sprintf(filter_msg, filter_fmt,
					filter_str);
		}
	}

	exclusion_msg = get_exclusion_names_msg(event);
	if (!exclusion_msg) {
		exclusion_msg = strdup(" [failed to retrieve exclusions]");
	}

	switch (event->type) {
	case LTTNG_EVENT_TRACEPOINT:
	{
		if (event->loglevel != -1) {
			MSG("%s%s (loglevel%s %s (%d)) (type: tracepoint)%s%s%s",
				indent6,
				event->name,
				logleveltype_string(event->loglevel_type),
				mi_lttng_loglevel_string(event->loglevel, handle->domain.type),
				event->loglevel,
				enabled_string(event->enabled),
				safe_string(exclusion_msg),
				safe_string(filter_msg));
		} else {
			MSG("%s%s (type: tracepoint)%s%s%s",
				indent6,
				event->name,
				enabled_string(event->enabled),
				safe_string(exclusion_msg),
				safe_string(filter_msg));
		}
		break;
	}
	case LTTNG_EVENT_FUNCTION:
		MSG("%s%s (type: function)%s%s", indent6,
				event->name, enabled_string(event->enabled),
				safe_string(filter_msg));
		if (event->attr.probe.addr != 0) {
			MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
		} else {
			MSG("%soffset: 0x%" PRIx64, indent8, event->attr.probe.offset);
			MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
		}
		break;
	case LTTNG_EVENT_PROBE:
		MSG("%s%s (type: probe)%s%s", indent6,
				event->name, enabled_string(event->enabled),
				safe_string(filter_msg));
		if (event->attr.probe.addr != 0) {
			MSG("%saddr: 0x%" PRIx64, indent8, event->attr.probe.addr);
		} else {
			MSG("%soffset: 0x%" PRIx64, indent8, event->attr.probe.offset);
			MSG("%ssymbol: %s", indent8, event->attr.probe.symbol_name);
		}
		break;
	case LTTNG_EVENT_FUNCTION_ENTRY:
		MSG("%s%s (type: function)%s%s", indent6,
				event->name, enabled_string(event->enabled),
				safe_string(filter_msg));
		MSG("%ssymbol: \"%s\"", indent8, event->attr.ftrace.symbol_name);
		break;
	case LTTNG_EVENT_SYSCALL:
		MSG("%s%s%s%s%s%s", indent6, event->name,
				(opt_syscall ? "" : " (type:syscall)"),
				enabled_string(event->enabled),
				bitness_event(event->flags),
				safe_string(filter_msg));
		break;
	case LTTNG_EVENT_NOOP:
		MSG("%s (type: noop)%s%s", indent6,
				enabled_string(event->enabled),
				safe_string(filter_msg));
		break;
	case LTTNG_EVENT_ALL:
		/* We should never have "all" events in list. */
		assert(0);
		break;
	}

	free(filter_msg);
	free(exclusion_msg);
}
Esempio n. 9
0
/*
 * List agent events for a specific session using the handle.
 *
 * Return CMD_SUCCESS on success else a negative value.
 */
static int list_session_agent_events(void)
{
	int ret = CMD_SUCCESS, count, i;
	struct lttng_event *events = NULL;

	count = lttng_list_events(handle, "", &events);
	if (count < 0) {
		ret = CMD_ERROR;
		ERR("%s", lttng_strerror(count));
		goto error;
	}

	if (lttng_opt_mi) {
		/* Mi print */
		ret = mi_list_session_agent_events(events, count);
		if (ret) {
			ret = CMD_ERROR;
			goto end;
		}
	} else {
		/* Pretty print */
		MSG("Events (Logger name):\n---------------------");
		if (count == 0) {
			MSG("%sNone\n", indent6);
			goto end;
		}

		for (i = 0; i < count; i++) {
			const char *filter_str;
			char *filter_msg = NULL;
			struct lttng_event *event = &events[i];

			ret = lttng_event_get_filter_expression(event,
					&filter_str);
			if (ret) {
				filter_msg = strdup(" [failed to retrieve filter]");
			} else if (filter_str) {
				const char * const filter_fmt =
						" [filter: '%s']";

				filter_msg = malloc(strlen(filter_str) +
						strlen(filter_fmt) + 1);
				if (filter_msg) {
					sprintf(filter_msg, filter_fmt,
							filter_str);
				}
			}

			if (event->loglevel_type !=
					LTTNG_EVENT_LOGLEVEL_ALL) {
				MSG("%s- %s%s (loglevel%s %s)%s", indent4,
						event->name,
						enabled_string(event->enabled),
						logleveltype_string(
							event->loglevel_type),
						mi_lttng_loglevel_string(
							event->loglevel,
							handle->domain.type),
						safe_string(filter_msg));
			} else {
				MSG("%s- %s%s%s", indent4, event->name,
						enabled_string(event->enabled),
						safe_string(filter_msg));
			}
			free(filter_msg);
		}

		MSG("");
	}

end:
	free(events);
error:
	return ret;
}
Esempio n. 10
0
gint
main (gint argc, gchar ** argv)
{
  gboolean res = FALSE;
  gchar *command = NULL, *input_file_name = NULL;
  BtEditApplication *app;
  GOptionContext *ctx = NULL;
  GOptionGroup *group;
  GError *err = NULL;

#ifdef ENABLE_NLS
  setlocale (LC_ALL, "");
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif /* ENABLE_NLS */

  bt_setup_for_local_install ();

  GOptionEntry options[] = {
    {"version", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
        (gpointer) parse_goption_arg, N_("Print application version"), NULL}
    ,
    {"command", 'c', 0, G_OPTION_ARG_STRING, &command, N_("Command name"),
        "{load}"}
    ,
    {"input-file", 'i', 0, G_OPTION_ARG_FILENAME, &input_file_name,
        N_("Input file name"), N_("<songfile>")}
    ,
    {NULL}
  };

  // init libraries
  ctx = g_option_context_new (NULL);
  //g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  group =
      g_option_group_new ("main", _("buzztrax-edit options"),
      _("Show buzztrax-edit options"), argv[0], NULL);
  g_option_group_add_entries (group, options);
  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
  g_option_context_set_main_group (ctx, group);

  bt_init_add_option_groups (ctx);
  g_option_context_add_group (ctx, btic_init_get_option_group ());
  g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
  g_option_context_add_group (ctx, clutter_get_option_group_without_init ());
  g_option_context_add_group (ctx, gtk_clutter_get_option_group ());

  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", safe_string (err->message));
    g_error_free (err);
    goto Done;
  }

  GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "bt-edit", 0,
      "music production environment / editor ui");

  // give some global context info
  g_set_prgname ("buzztrax-edit");
  g_set_application_name ("Buzztrax");
  gtk_window_set_default_icon_name ("buzztrax");
  g_setenv ("PULSE_PROP_media.role", "production", TRUE);

  extern gboolean bt_memory_audio_src_plugin_init (GstPlugin * const plugin);
  gst_plugin_register_static (GST_VERSION_MAJOR,
      GST_VERSION_MINOR,
      "memoryaudiosrc",
      "Plays audio from memory",
      bt_memory_audio_src_plugin_init,
      VERSION, "LGPL", PACKAGE, PACKAGE_NAME, "http://www.buzztrax.org");

  GST_INFO ("starting: thread=%p", g_thread_self ());

  app = bt_edit_application_new ();

  // set a default command, if a file is given
  if (!command && BT_IS_STRING (input_file_name)) {
    command = g_strdup ("l");
  }

  if (command) {
    // depending on the options call the correct method
    if (!strcmp (command, "l") || !strcmp (command, "load")) {
      if (!BT_IS_STRING (input_file_name)) {
        usage (argc, argv, ctx);
        // if commandline options where wrong, just start
        res = bt_edit_application_run (app);
      } else {
        res = bt_edit_application_load_and_run (app, input_file_name);
      }
    } else {
      usage (argc, argv, ctx);
      // if commandline options where wrong, just start
      res = bt_edit_application_run (app);
    }
  } else {
    res = bt_edit_application_run (app);
  }

  // free application
  GST_INFO ("app %" G_OBJECT_REF_COUNT_FMT, G_OBJECT_LOG_REF_COUNT (app));
  g_object_unref (app);

Done:
  g_free (command);
  g_free (input_file_name);
  g_option_context_free (ctx);
  return !res;
}