#include <stdio.h>
#include <string.h>
#include <glib.h>
+#include <math.h>
#include "meta.h"
#include "util.h"
#include "dump.h"
#include "get.h"
#include "mono/metadata/loader.h"
#include "mono/metadata/class.h"
+#include "mono/utils/mono-compiler.h"
+
+#ifndef HAVE_ISINF
+
+#ifdef HAVE_IEEEFP_H
+extern int isinf (double);
+#endif
+
+#endif
void
dump_table_assembly (MonoImage *m)
fprintf (output, "Typespec Table\n");
for (i = 1; i <= t->rows; i++){
- char *typespec = get_typespec (m, i);
+ char *typespec = get_typespec (m, i, TRUE, NULL);
fprintf (output, "%d: %s\n", i, typespec);
g_free (typespec);
first_m = last_m;
}
mono_metadata_decode_row (t, i - 1, cols, MONO_FIELD_SIZE);
- sig = get_field_signature (m, cols [MONO_FIELD_SIGNATURE]);
+ sig = get_field_signature (m, cols [MONO_FIELD_SIGNATURE], NULL);
flags = field_flags (cols [MONO_FIELD_FLAGS]);
fprintf (output, "%d: %s %s: %s\n",
i,
int i, kind, idx;
char *x, *xx;
char *sig;
- const char *blob, *ks;
+ const char *blob, *ks = NULL;
fprintf (output, "MemberRef Table (1..%d)\n", t->rows);
break;
case 4:
ks = "TypeSpec";
- xx = get_typespec (m, idx);
+ xx = get_typespec (m, idx, FALSE, NULL);
x = g_strconcat (xx, ".", mono_metadata_string_heap (m, cols [MONO_MEMBERREF_NAME]), NULL);
g_free (xx);
break;
blob = mono_metadata_blob_heap (m, cols [MONO_MEMBERREF_SIGNATURE]);
mono_metadata_decode_blob_size (blob, &blob);
if (*blob == 0x6) { /* it's a field */
- sig = get_field_signature (m, cols [MONO_MEMBERREF_SIGNATURE]);
+ sig = get_field_signature (m, cols [MONO_MEMBERREF_SIGNATURE], NULL);
} else {
- sig = get_methodref_signature (m, cols [MONO_MEMBERREF_SIGNATURE], NULL);
+ sig = get_methodref_signature (m, cols [MONO_MEMBERREF_SIGNATURE], NULL, NULL);
}
fprintf (output, "%d: %s[%d] %s\n\tResolved: %s\n\tSignature: %s\n\t\n",
i + 1,
for (i = 0; i < t->rows; i++){
guint32 cols [MONO_CONSTANT_SIZE];
- const char *parent = desc [cols [MONO_CONSTANT_PARENT] & MONO_HASCONSTANT_MASK];
-
+ const char *parent;
mono_metadata_decode_row (t, i, cols, MONO_CONSTANT_SIZE);
+ parent = desc [cols [MONO_CONSTANT_PARENT] & MONO_HASCONSTANT_MASK];
fprintf (output, "%d: Parent= %s: %d %s\n",
i + 1, parent, cols [MONO_CONSTANT_PARENT] >> MONO_HASCONSTANT_BITS,
bsize = mono_metadata_decode_blob_size (ptr, &ptr);
/* ECMA claims 0x08 ... */
if (*ptr != 0x28 && *ptr != 0x08)
- g_warning("incorrect signature in propert blob: 0x%x", *ptr);
+ g_warning("incorrect signature in propert blob: 0x%x", *ptr);
ptr++;
pcount = mono_metadata_decode_value (ptr, &ptr);
- ptr = get_type (m, ptr, &type);
+ ptr = get_type (m, ptr, &type, NULL);
fprintf (output, "%d: %s %s (",
i + 1, type, mono_metadata_string_heap (m, cols [MONO_PROPERTY_NAME]));
g_free (type);
for (j = 0; j < pcount; j++){
- ptr = get_param (m, ptr, &type);
- fprintf (output, "%s%s", j > 0? ", " : "",type);
- g_free (type);
+ ptr = get_param (m, ptr, &type, NULL);
+ fprintf (output, "%s%s", j > 0? ", " : "",type);
+ g_free (type);
}
fprintf (output, ") %s\n", flags);
}
mono_metadata_decode_row (t, i, cols, MONO_EVENT_SIZE);
name = mono_metadata_string_heap (m, cols [MONO_EVENT_NAME]);
- type = get_typedef_or_ref (m, cols [MONO_EVENT_TYPE]);
+ type = get_typedef_or_ref (m, cols [MONO_EVENT_TYPE], NULL);
fprintf (output, "%d: %s %s %s\n", i + 1, type, name,
cols [MONO_EVENT_FLAGS] & 0x200 ? "specialname " : "");
g_free (type);
sigblob = mono_metadata_blob_heap (m, cols [MONO_METHOD_SIGNATURE]);
mono_metadata_decode_blob_size (sigblob, &sigblob);
method = mono_metadata_parse_method_signature (m, i, sigblob, &sigblob);
- sig = dis_stringify_method_signature (m, method, i, FALSE);
+ sig = dis_stringify_method_signature (m, method, i, NULL, FALSE);
fprintf (output, "%d: %s (param: %d)\n", i, sig, cols [MONO_METHOD_PARAMLIST]);
g_free (sig);
mono_metadata_free_method_signature (method);
mono_metadata_decode_row (t, i - 1, cols, MONO_IMPLMAP_SIZE);
- method = get_method (m, MONO_TOKEN_METHOD_DEF | (cols [MONO_IMPLMAP_MEMBER] >> MONO_MEMBERFORWD_BITS));
+ method = get_method (m, MONO_TOKEN_METHOD_DEF | (cols [MONO_IMPLMAP_MEMBER] >> MONO_MEMBERFORWD_BITS), NULL);
fprintf (output, "%d: %s %d (%s %s)\n", i,
method,
}
}
-static guint32
-method_dor_to_token (guint32 idx) {
- switch (idx & MONO_METHODDEFORREF_MASK) {
- case MONO_METHODDEFORREF_METHODDEF:
- return MONO_TOKEN_METHOD_DEF | (idx >> MONO_METHODDEFORREF_BITS);
- case MONO_METHODDEFORREF_METHODREF:
- return MONO_TOKEN_MEMBER_REF | (idx >> MONO_METHODDEFORREF_BITS);
- }
- return -1;
-}
-
void
dump_table_methodimpl (MonoImage *m)
{
mono_metadata_decode_row (t, i - 1, cols, MONO_METHODIMPL_SIZE);
class = get_typedef (m, cols [MONO_METHODIMPL_CLASS]);
- impl = get_method (m, method_dor_to_token (cols [MONO_METHODIMPL_BODY]));
- decl = get_method (m, method_dor_to_token (cols [MONO_METHODIMPL_DECLARATION]));
+ impl = get_method (m, method_dor_to_token (cols [MONO_METHODIMPL_BODY]), NULL);
+ decl = get_method (m, method_dor_to_token (cols [MONO_METHODIMPL_DECLARATION]), NULL);
fprintf (output, "%d: %s\n\tdecl: %s\n\timpl: %s\n", i, class, decl, impl);
g_free (class);
g_free (impl);
mono_metadata_decode_row (t, i - 1, cols, MONO_INTERFACEIMPL_SIZE);
fprintf (output, "%d: %s implements %s\n", i,
- get_typedef (m, cols [MONO_INTERFACEIMPL_CLASS]),
- get_typedef_or_ref (m, cols [MONO_INTERFACEIMPL_INTERFACE]));
+ get_typedef (m, cols [MONO_INTERFACEIMPL_CLASS]),
+ get_typedef_or_ref (m, cols [MONO_INTERFACEIMPL_INTERFACE], NULL));
}
}
p += 4;
break;
case MONO_TYPE_U8:
- g_string_sprintfa (res, "%lld", read64 (p));
+ g_string_sprintfa (res, "%lld", (long long)read64 (p));
p += 8;
break;
case MONO_TYPE_I8:
- g_string_sprintfa (res, "%lld", (gint64)read64 (p));
+ g_string_sprintfa (res, "%lld", (long long)read64 (p));
p += 8;
break;
case MONO_TYPE_R4: {
float val;
+ int inf;
readr4 (p, &val);
- g_string_sprintfa (res, "%g", val);
+ inf = isinf (val);
+ if (inf == -1)
+ g_string_sprintfa (res, "(00 00 80 ff)"); /* negative infinity */
+ else if (inf == 1)
+ g_string_sprintfa (res, "(00 00 80 7f)"); /* positive infinity */
+ else if (isnan (val))
+ g_string_sprintfa (res, "(00 00 c0 ff)"); /* NaN */
+ else
+ g_string_sprintfa (res, "%g", val);
p += 4;
break;
}
case MONO_TYPE_R8: {
double val;
+ int inf;
+
readr8 (p, &val);
- g_string_sprintfa (res, "%g", val);
+ inf = isinf (val);
+ if (inf == -1)
+ g_string_sprintfa (res, "(00 00 00 00 00 00 f0 ff)"); /* negative infinity */
+ else if (inf == 1)
+ g_string_sprintfa (res, "(00 00 00 00 00 00 f0 7f)"); /* positive infinity */
+ else if (isnan (val))
+ g_string_sprintfa (res, "(00 00 00 00 00 00 f8 ff)"); /* NaN */
+ else
+ g_string_sprintfa (res, "%g", val);
p += 8;
break;
}
g_warning ("Unknown table for custom attr type %08x", cols [MONO_CUSTOM_ATTR_TYPE]);
break;
}
- method = get_method (m, mtoken);
+ method = get_method (m, mtoken, NULL);
meth = mono_get_method (m, mtoken, NULL);
params = custom_attr_params (m, mono_method_signature (meth), mono_metadata_blob_heap (m, cols [MONO_CUSTOM_ATTR_VALUE]));
fprintf (output, "%d: %s: %s [%s]\n", i, desc, method, params);
return "RequestOptional";
case SECURITY_ACTION_REQREFUSE:
return "RequestRefuse";
+ /* Special actions (for non CAS permissions) */
+ case SECURITY_ACTION_NONCASDEMAND:
+ return "NonCasDemand";
+ case SECURITY_ACTION_NONCASLINKDEMAND:
+ return "NonCasLinkDemand";
+ case SECURITY_ACTION_NONCASINHERITANCE:
+ return "NonCasInheritance";
+ /* Fx 2.0 actions (for both CAS and non-CAS permissions) */
+ case SECURITY_ACTION_LINKDEMANDCHOICE:
+ return "LinkDemandChoice";
+ case SECURITY_ACTION_INHERITDEMANDCHOICE:
+ return "InheritanceDemandChoice";
+ case SECURITY_ACTION_DEMANDCHOICE:
+ return "DemandChoice";
default:
g_snprintf (buf, sizeof (buf), "0x%04X", val);
return buf;
char *sig;
mono_metadata_decode_row (t, i - 1, cols, MONO_GENERICPARAM_SIZE);
- sig = get_type_or_methdef (m, cols [MONO_GENERICPARAM_OWNER]);
+ // sig = get_type_or_methdef (m, cols [MONO_GENERICPARAM_OWNER]);
+ sig = g_strdup_printf ("%x", cols [MONO_GENERICPARAM_OWNER]);
fprintf (output, "%d: %d, flags=%d, owner=%s %s\n", i,
cols [MONO_GENERICPARAM_NUMBER],
cols [MONO_GENERICPARAM_FLAGS], sig,
/* build a methodspec token to get the method */
token = MONO_TOKEN_METHOD_SPEC | i;
- method = get_method (m, token);
+ method = get_method (m, token, NULL);
- sig = get_method_type_param (m, cols [MONO_METHODSPEC_SIGNATURE]);
+ sig = get_method_type_param (m, cols [MONO_METHODSPEC_SIGNATURE], NULL);
fprintf (output, "%d: %s, %s\n", i, method, sig);
g_free (sig);
g_free (method);
char *sig;
mono_metadata_decode_row (t, i - 1, cols, MONO_GENPARCONSTRAINT_SIZE);
- sig = get_typedef_or_ref (m, cols [MONO_GENPARCONSTRAINT_CONSTRAINT]);
+ // sig = get_typedef_or_ref (m, cols [MONO_GENPARCONSTRAINT_CONSTRAINT], NULL);
+ sig = g_strdup_printf ("%x", cols [MONO_GENPARCONSTRAINT_CONSTRAINT]);
fprintf (output, "%d: gen-par=%d, Constraint=%s\n", i,
cols [MONO_GENPARCONSTRAINT_GENERICPAR], sig);
g_free (sig);
fprintf (output, "Stand alone signature (1..%d)\n", t->rows);
for (i = 1; i <= t->rows; i++) {
- char *sig;
- const char *locals_ptr;
+ const char *locals_ptr;
int j, bsize;
mono_metadata_decode_row (t, i - 1, cols, MONO_STAND_ALONE_SIGNATURE_SIZE);