/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/* hsdis-demo.c -- dump a range of addresses as native instructions
This demonstrates the protocol required by the HotSpot PrintAssembly option.
*/
#include "hsdis.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
void greet(const char*);
void disassemble(void*, void*);
void end_of_file();
int raw = 0;
int xml = 0;
int greeted = 0;
int i;
for (i = 1; i < ac; i++) {
if (arg[0] == '-') {
xml ^= 1;
raw ^= 1;
else
continue;
}
greeted = 1;
}
if (!greeted)
greet("world");
printf("...And now for something completely different:\n");
printf("Cheers!\n");
}
}
void end_of_file() { }
/* don't disassemble after this point... */
#include "dlfcn.h"
static void* decode_instructions_pv = 0;
static const char* hsdis_path[] = {
#ifdef TARGET_DIR
#endif
};
static const char* load_decode_instructions() {
while (1) {
if (decode_instructions_pv != NULL)
return NULL;
return "plugin does not defined "DECODE_INSTRUCTIONS_NAME;
}
}
}
return NULL;
}
/* does the event match the tag, followed by a null, space, or slash? */
if (cookie != event_cookie)
if (xml) {
/* We could almost do a printf(event, arg),
but for the sake of a better demo,
we dress the result up as valid XML.
*/
if (!fmt) {
if (event[0] != '/') {
} else {
}
} else {
if (event[0] != '/') {
printf(">");
} else {
}
}
}
/* basic action for <insn>: */
/* basic action for </insn>:
(none, plugin puts the newline for us
*/
/* basic action for <addr/>: */
if (name) {
/* return non-null to notify hsdis not to print the addr */
return arg;
}
}
/* null return is always safe; can mean "I ignored it" */
return NULL;
}
#define fprintf_callback \
exit(1);
}
void* res;
} else if (raw) {
} else {
handle_event, (void*) event_cookie,
options);
}
}