}
static int
-id_from_string (MonoString *instance, gboolean is_process)
+id_from_string (const gchar *id_str, gboolean is_process)
{
int id = -1;
- if (mono_string_length (instance)) {
- char *id_str = mono_string_to_utf8 (instance);
+ if (strcmp("", id_str) != 0) {
char *end;
id = strtol (id_str, &end, 0);
if (end == id_str && !is_process)
id = -1;
- g_free (id_str);
}
return id;
}
}
static void*
-cpu_get_impl (MonoString* counter, MonoString* instance, int *type, MonoBoolean *custom)
+cpu_get_impl (MonoString* counter, const gchar* instance, int *type, MonoBoolean *custom)
{
int id = id_from_string (instance, FALSE) << 5;
const CounterDesc *cdesc;
}
static void*
-network_get_impl (MonoString* counter, MonoString* instance, int *type, MonoBoolean *custom)
+network_get_impl (MonoString* counter, const gchar* instance, int *type, MonoBoolean *custom)
{
const CounterDesc *cdesc;
NetworkVtableArg *narg;
*custom = FALSE;
if ((cdesc = get_counter_in_category (&predef_categories [CATEGORY_NETWORK], counter))) {
- instance_name = mono_string_to_utf8 (instance);
+ instance_name = g_strdup (instance);
narg = g_new0 (NetworkVtableArg, 1);
narg->id = cdesc->id;
narg->name = instance_name;
}
static void*
-process_get_impl (MonoString* counter, MonoString* instance, int *type, MonoBoolean *custom)
+process_get_impl (MonoString* counter, const gchar* instance, int *type, MonoBoolean *custom)
{
int id = id_from_string (instance, TRUE) << 5;
const CounterDesc *cdesc;
}
static void*
-mono_mem_get_impl (MonoString* counter, MonoString* instance, int *type, MonoBoolean *custom)
+mono_mem_get_impl (MonoString* counter, const gchar* instance, int *type, MonoBoolean *custom)
{
const CounterDesc *cdesc;
*custom = FALSE;
}
static ImplVtable*
-predef_vtable (void *arg, MonoString *instance)
+predef_vtable (void *arg, const gchar *pids)
{
MonoSharedArea *area;
PredefVtable *vtable;
- char *pids = mono_string_to_utf8 (instance);
int pid;
pid = atoi (pids);
- g_free (pids);
area = load_sarea_for_pid (pid);
if (!area)
return NULL;
}
static void*
-predef_writable_get_impl (int cat, MonoString* counter, MonoString* instance, int *type, MonoBoolean *custom)
+predef_writable_get_impl (int cat, MonoString* counter, const gchar *instance, int *type, MonoBoolean *custom)
{
const CounterDesc *cdesc;
*custom = TRUE;
if ((cdesc = get_counter_in_category (&predef_categories [cat], counter))) {
*type = cdesc->type;
- if (instance == NULL || mono_string_compare_ascii (instance, "") == 0)
+ if (instance == NULL || strcmp (instance, "") == 0)
return create_vtable (GINT_TO_POINTER ((cdesc->id << 16) | cat), predef_writable_counter, predef_writable_update);
else
return predef_vtable (GINT_TO_POINTER ((cdesc->id << 16) | cat), instance);
}
static void*
-custom_get_impl (SharedCategory *cat, MonoString* counter, MonoString* instance, int *type)
+custom_get_impl (SharedCategory *cat, MonoString *counter, MonoString* instance, int *type, MonoError *error)
{
SharedCounter *scounter;
SharedInstance* inst;
char *name;
+ mono_error_init (error);
scounter = find_custom_counter (cat, counter);
if (!scounter)
return NULL;
+ name = mono_string_to_utf8_checked (counter, error);
+ return_val_if_nok (error, NULL);
*type = simple_type_to_type [scounter->type];
- name = mono_string_to_utf8 (counter);
inst = custom_get_instance (cat, scounter, name);
g_free (name);
if (!inst)
mono_perfcounter_get_impl (MonoString* category, MonoString* counter, MonoString* instance,
MonoString* machine, int *type, MonoBoolean *custom)
{
+ MonoError error;
const CategoryDesc *cdesc;
+ void *result = NULL;
/* no support for counters on other machines */
if (mono_string_compare_ascii (machine, "."))
return NULL;
if (!scat)
return NULL;
*custom = TRUE;
- return custom_get_impl (scat, counter, instance, type);
+ result = custom_get_impl (scat, counter, instance, type, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
+ return result;
}
+ gchar *c_instance = mono_string_to_utf8_checked (instance, &error);
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
switch (cdesc->id) {
case CATEGORY_CPU:
- return cpu_get_impl (counter, instance, type, custom);
+ result = cpu_get_impl (counter, c_instance, type, custom);
+ break;
case CATEGORY_PROC:
- return process_get_impl (counter, instance, type, custom);
+ result = process_get_impl (counter, c_instance, type, custom);
+ break;
case CATEGORY_MONO_MEM:
- return mono_mem_get_impl (counter, instance, type, custom);
+ result = mono_mem_get_impl (counter, c_instance, type, custom);
+ break;
case CATEGORY_NETWORK:
- return network_get_impl (counter, instance, type, custom);
+ result = network_get_impl (counter, c_instance, type, custom);
+ break;
case CATEGORY_JIT:
case CATEGORY_EXC:
case CATEGORY_GC:
case CATEGORY_SECURITY:
case CATEGORY_ASPNET:
case CATEGORY_THREADPOOL:
- return predef_writable_get_impl (cdesc->id, counter, instance, type, custom);
+ result = predef_writable_get_impl (cdesc->id, counter, c_instance, type, custom);
+ break;
}
- return NULL;
+ g_free (c_instance);
+ return result;
}
MonoBoolean
SharedCategory *cat;
/* FIXME: ensure there isn't a category created already */
- mono_error_init (&error);
name = mono_string_to_utf8_checked (category, &error);
if (!mono_error_ok (&error))
goto failure;
int
mono_perfcounter_instance_exists (MonoString *instance, MonoString *category, MonoString *machine)
{
+ MonoError error;
const CategoryDesc *cdesc;
SharedInstance *sinst;
char *name;
scat = find_custom_category (category);
if (!scat)
return FALSE;
- name = mono_string_to_utf8 (instance);
+ name = mono_string_to_utf8_checked (instance, &error);
+ if (mono_error_set_pending_exception (&error))
+ return FALSE;
sinst = find_custom_instance (scat, name);
g_free (name);
if (sinst)