File: method_info.c

package info (click to toggle)
jmp 0.48-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,692 kB
  • ctags: 1,732
  • sloc: ansic: 13,985; sh: 8,611; makefile: 526; yacc: 318; java: 18
file content (100 lines) | stat: -rw-r--r-- 2,579 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <cls.h>
#include <method.h>
#include <ui.h>
#include <mvector.h>
#include <methodtime.h>
#include <gtkutils.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <jmp-config.h>

#define BLEN 32
static char buf[BLEN];

static char* get_method_class (method* m) {
    return m->owner->name;
}

static char* get_source_file (method* m) {
    return m->owner->source_name;
}

static char* get_start_line (method* m) {
    snprintf (buf, 32, "%d", m->start_lineno);
    return buf;
}

static char* get_end_line (method* m) {
    snprintf (buf, BLEN, "%d", m->end_lineno);
    return buf;
}

static char* get_secs (method* m) {
    jlong jsec, jnsec, rsec, rnsec; 
    methodtime* mt = method_get_time_used (m);
    methodtime* rt = method_get_restore_time (m);
    jsec = mt->tv / 1000000000ll;
    jnsec = mt->tv % 1000000000ll;
    rsec = rt->tv / 1000000000ll;
    rnsec = rt->tv % 1000000000ll;
    snprintf (buf, BLEN, "%lld.%06lld (%lld.%06lld)", 
	      jsec, jnsec, 
	      rsec, rnsec);
    return buf;
}

static char* get_calls (method* m) {
    snprintf (buf, BLEN, "%ld (%ld)", 
	      method_get_calls (m), 
	      method_get_restore_calls (m));
    return buf;    
}

/** methods used to show a window with method info.. */
void show_method_info (method* m) {
    
    GtkWidget* win;
    GtkWidget* table;

    gchar *labels[] = { _("Class"),
			_("JMP Signature"), 
			_("Method name"), 
			_("Method signature"),
			_("Source file"),
			_("Start line"),
			_("End line"),
			_("secs"),
			_("calls"),
			NULL};
    
    char* ((*mp[])(method* m)) = { get_method_class,
				   method_get_method_jmpname, 
				   method_get_method_name,
				   method_get_method_signature, 
				   get_source_file,
				   get_start_line,
				   get_end_line,
				   get_secs,
				   get_calls,
				   NULL};
        
    win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_object_set_data (GTK_OBJECT (win), "win", win);
    gtk_window_set_title (GTK_WINDOW (win), _("Method info"));

    table = get_table (labels, (tablefunc*)mp, m);
    gtk_container_add (GTK_CONTAINER (win), table);
    gtk_widget_show_all (win);
}

/* Emacs Local Variables: */
/* Emacs mode:C */
/* Emacs c-indentation-style:"gnu" */
/* Emacs c-hanging-braces-alist:((brace-list-open)(brace-entry-open)(defun-open after)(substatement-open after)(block-close . c-snug-do-while)(extern-lang-open after)) */
/* Emacs c-cleanup-list:(brace-else-brace brace-elseif-brace space-before-funcall) */
/* Emacs c-basic-offset:4 */
/* Emacs End: */