bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hurd/utils/rpctrace.c - print RPC names as well as the ID


From: Michael Oberg
Subject: hurd/utils/rpctrace.c - print RPC names as well as the ID
Date: Fri, 25 Jan 2002 21:48:35 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.6+) Gecko/20011207

Below are my additions to hurd/utils/rpctrace.c in order to print out
the RPC names instead of just the ID.  The name->id associations are
expected to be located in /etc/rpctrace/msgids.  I used the
associations that Roland McGrath posted to this list back in June in
the thread "rpctrace improvement -- how I'm going on" (reposted below
for convenience, minus the trailing semicolons).  I make the assumption
that the reply RPC's are not listed in the file, and so the function
adds a second RPC name with an ID incremented by 100 for each routine
actually listed in the file. The problem with this is when I fiddled around
with generating the associations from my own /include/hurd/*.defs and
/include/mach/*.defs, I noticed that reply routines were sometimes
explicitly defined. I assume that this will iron itself out once a
better way is found to create the associations.

Thus, there is still a need to find an appropriate way to generate the
associations. Roland, in the message referred to above, you mentioned
that you "will tinker a bit with adding a mig option to produce these files
cleanly.".  Is this still the current thought on how best to proceed
with generating a file for rpctrace to use in the long term?

My next steps will be to add the option to parse user supplied files, via
a -I option, and a lot of work on the output formatting.

I am a novice C programmer at best, so any suggestions and/or additions
would be greatly appreciated.

Michael Oberg
oberg@adhocinc.com

p.s.  Im still confused as to what the ***locp argument to the ihash_add
function is for, and how it should be used.  Can it be NULL, if im not
interested in using the explicit cleanup function?

------------------------------------------------------------------------
Example output: (first lines from `rpctrace ls`)

task2245->vm_statistics(2030) () = 0 {4096 54201 3071 3202 3182 638827 0 184906 66885 2585225 177952 560277 507240}
task2245->vm_region(2029) (134217728) = 0 134512640 45056 5 7 1 0  101 0
task2245->mach_port_deallocate_rpc(3206) (pn{  5}) = 0
task2245->vm_region(2029) (134557696) = 0 134557696 4096 3 7 1 0  103 0
task2245->mach_port_deallocate_rpc(3206) (pn{  5}) = 0
task2245->vm_region(2029) (134561792) = 0x3 ((os/kern) no space available)
task2245->vm_map_rpc(2089) (134561792 -1208303616 0 0  (null) 0 1 0 0 1) = 0 
134561792
task2245->vm_map_rpc(2089) (0 4096 0 0  (null) 0 1 0 0 1) = 0 0
task2245->task_get_special_port(2058) (4) = 0  101
101->exec_startup_get_info(30500) () = 0 134518096 134512692 192 151552 16777216 0 "ls" "PWD=/home/oberg/projects/rpctrace" {103 105 106 107} {108 109 110 111 112 (null)} {18 0 0 0 0}
task2245->mach_port_deallocate_rpc(3206) (pn{  5}) = 0
task2245->vm_deallocate_rpc(2023) (134561792 -1208303616) = 0
task2245->vm_map_rpc(2089) (0 4096 0 1  (null) 0 0 3 7 1) = 0 16949248
...

------------------------------------------------------------------------
Patch:

--- ./rpctrace.c.orig   Thu Jan 24 05:07:12 2002
+++ ./rpctrace.c        Fri Jan 25 12:06:51 2002
@@ -44,7 +44,74 @@
 static const char *doc =
 "Trace Mach Remote Procedure Calls."
 "\v.";
+static const char *msgids_filename = "/etc/rpctrace/msgids";
+ihash_t msgids;
+
+/* Parse the system /etc/rpctrace/msgids file.
+   syntax: '[routine_name] [routine_id]\n' */
+void
+parse_system_msgids (void)
+{
+  FILE    *msgids_file;
+  error_t err;
+  char    *linebuf = NULL;
+  size_t  linebufsize = 0;
+  char    routine_name_buf[256];
+  int     routine_id;
+  int     linenum;
+  void    **loco; /* crazyness */
+  void    *locp = &loco;
+
+  /* Open system msgids file */
+  msgids_file = fopen (msgids_filename, "r");
+  if (!msgids_file)
+    error (1, errno, "%s", msgids_filename);
+
+  /* Create ihash */
+  err = ihash_create (&msgids);
+  assert_perror (err);
+
+  /* Parse msgids file line by line, adding each routine->id pair into
+     the msgids ihash. */
+  linenum = 0;
+  while (getline(&linebuf, &linebufsize, msgids_file) != EOF)
+  {
+    linenum++;
+    if (sscanf(linebuf, "%s %d", routine_name_buf, &routine_id) == 2)
+    {
+      /* Allocate storage for each new routine_name */
+      /* 7 extra chars in reply to account for "(reply)", postpended below */
+      char *routine_name       = (char *) malloc (strlen(routine_name_buf)+1);
+      char *routine_name_reply = (char *) malloc (strlen(routine_name_buf)+8);
+
+      /* Copy the buffer's contents into each new string */
+      strcpy(routine_name,       routine_name_buf);
+      strcpy(routine_name_reply, routine_name_buf);
+
+      /* Add the text "(reply)" to differentiate the reply routine name */
+      strcat(routine_name_reply, "(reply)");
+
+      /* Add null termination to the end of the strings */
+      routine_name[strlen(routine_name)]             = '\0';
+      routine_name_reply[strlen(routine_name_reply)] = '\0';
+
+      /* Add routine and routine_id to msgids hash */
+      err = ihash_add (msgids, routine_id, routine_name, locp);
+      assert_perror(err);
+
+      /* Add "routine(reply)" and routine_id+100 to msgids hash */
+      routine_id += 100;
+      err = ihash_add (msgids, routine_id, routine_name_reply, locp);
+      assert_perror(err);
+    }
+    else
+    {
+      fprintf (stdout, "Bad input line:%d, in file: %s\n",
+              linenum, msgids_filename);
+    }
+  }
+}
+
 /* We keep one of these structures for each port right we are tracing.  */
 struct traced_info
 {
@@ -692,10 +759,13 @@
   expected_reply_port = msg->msgh_local_port;

   if (receiver->name != 0)
-    fprintf (ostream, "%4s->%5u (", receiver->name, msg->msgh_id);
+    fprintf (ostream, "%4s->%s(%4u) (",
+             receiver->name,
+             ihash_find(msgids, msg->msgh_id), msg->msgh_id);
   else
-    fprintf (ostream, "%4u->%5u (",
- (unsigned int) receiver->pi.port_right, msg->msgh_id);
+    fprintf (ostream, "%4u->%s(%4u) (",
+             (unsigned int) receiver->pi.port_right,
+             ihash_find(msgids, msg->msgh_id), msg->msgh_id);
 }

 static void
@@ -742,7 +812,7 @@
        fprintf (ostream, " > ");
       else
        /* Weirdo.  */
- fprintf (ostream, " >(%u) ", reply->Head.msgh_id); + fprintf (ostream, " >(%s) ", ihash_find(msgids, reply->Head.msgh_id));
     }

   if (reply->RetCode == 0)
@@ -945,6 +1015,10 @@
   else
     ostream = stderr;
   setlinebuf (ostream);
+
+  /* Parse /etc/rpctrace/msgids file    */
+  parse_system_msgids();

   traced_bucket = ports_create_bucket ();
   traced_class = ports_create_class (0, &traced_dropweak);


------------------------------------------------------------------------
/etc/rpctrace/msgids:

default_pager_info  2276
default_pager_object_create 2275
default_pager_object_pages 2278
default_pager_objects 2277
default_pager_paging_file 2279
default_pager_register_fileserver 2280
device_close 2801
device_get_status 2811
device_map 2809
device_open 2800
device_open_request 2800
device_read 2804
device_read_inband 2805
device_read_request 2804
device_read_request_inband 2805
device_set_filter 2812
device_set_status 2810
device_write 2802
device_write_inband 2803
device_write_request 2802
device_write_request_inband 2803
dp_helper_paging_space 888888
exception_raise 2400
host_adjust_time 2633
host_get_boot_info 2642
host_get_time 2634
host_info 2638
host_kernel_version 2619
host_processors 2600
host_processor_set_priv 2630
host_processor_sets 2629
host_reboot 2635
host_set_time 2632
mach_port_allocate_name_rpc 3203
mach_port_allocate_rpc 3204
mach_port_deallocate_rpc 3206
mach_port_destroy 3205
mach_port_extract_right 3216
mach_port_get_receive_status 3217
mach_port_get_refs 3207
mach_port_get_set_status 3212
mach_port_insert_right_rpc 3215
mach_port_mod_refs 3208
mach_port_move_member 3213
mach_port_names 3200
mach_port_rename 3202
mach_port_request_notification 3214
mach_port_set_mscount 3211
mach_port_set_qlimit 3210
mach_port_set_seqno 3218
mach_ports_lookup 2034
mach_ports_register 2033
mach_port_type 3201
memory_object_change_attributes 2095
memory_object_change_completed 2209
memory_object_copy 2202
memory_object_create 2250
memory_object_data_error 2090
memory_object_data_initialize 2251
memory_object_data_provided 2038
memory_object_data_request 2203
memory_object_data_return 2208
memory_object_data_supply 2093
memory_object_data_unavailable 2039
memory_object_data_unlock 2204
memory_object_data_write 2205
memory_object_destroy 2092
memory_object_get_attributes 2040
memory_object_init 2200
memory_object_lock_completed 2206
memory_object_lock_request 2044
memory_object_ready 2094
memory_object_set_attributes 2091
memory_object_supply_completed 2207
memory_object_terminate 2201
old_mach_port_get_receive_status 3209
processor_assign 2611
processor_control 2641
processor_exit 2604
processor_get_assignment 2612
processor_info 2639
processor_set_create 2608
processor_set_default 2606
processor_set_destroy 2609
processor_set_info 2640
processor_set_max_priority 2623
processor_set_policy_disable 2626
processor_set_policy_enable 2625
processor_set_tasks 2627
processor_set_threads 2628
processor_start 2603
task_assign 2616
task_assign_default 2617
task_create_rpc 2007
task_disable_pc_sampling 4001
task_enable_pc_sampling 4000
task_get_assignment 2618
task_get_emulation_vector 2009
task_get_sampled_pcs 4002
task_get_special_port 2058
task_info 2012
task_priority 2622
task_ras_control 2071
task_resume 2057
task_set_emulation 2070
task_set_emulation_vector 2010
task_set_special_port_rpc 2059
task_suspend_rpc 2056
task_terminate_rpc 2008
task_threads 2011
thread_abort 2064
thread_assign 2613
thread_assign_default 2614
thread_create 2061
thread_depress_abort_rpc 2631
thread_disable_pc_sampling 4004
thread_enable_pc_sampling 4003
thread_get_assignment 2615
thread_get_sampled_pcs 4005
thread_get_special_port 2067
thread_get_state 2017
thread_info 2019
thread_max_priority 2621
thread_policy 2624
thread_priority 2620
thread_resume 2063
thread_set_special_port 2068
thread_set_state 2018
thread_suspend 2062
thread_terminate 2016
thread_wire 2637
vm_allocate_rpc 2021
vm_copy 2028
vm_deallocate_rpc 2023
vm_inherit 2025
vm_machine_attribute 2099
vm_map_rpc 2089
vm_protect 2024
vm_read 2026
vm_region 2029
vm_set_default_memory_manager 2041
vm_statistics 2030
vm_wire 2636
vm_write 2027
xxx_cpu_control 2049
xxx_device_get_status 2807
xxx_device_set_filter 2808
xxx_device_set_status 2806
xxx_host_info 2047
xxx_memory_object_lock_request 2043
xxx_processor_set_default_priv 2607
xxx_slot_info 2048
xxx_task_get_emulation_vector 2045
xxx_task_info 2060
xxx_task_set_emulation_vector 2046
xxx_thread_get_state 2065
xxx_thread_info 2069
xxx_thread_set_state 2066
yyy_host_info 2601
yyy_processor_control 2605
yyy_processor_info 2602
yyy_processor_set_info 2610
auth_getids 25000
auth_makeauth 25001
auth_server_authenticate 25003
auth_user_authenticate 25002
crash_dump_task 32000
dir_link 20023
dir_lookup 20018
dir_mkdir 20020
dir_mkfile 20025
dir_notice_changes 20026
dir_readdir 20019
dir_rename 20024
dir_rmdir 20021
dir_unlink 20022
exec_exec 30000
exec_init 30002
exec_setexecdata 30003
exec_startup_get_info 30500
file_chauthor 20002
file_check_access 20009
file_chflags 20004
file_chmod 20003
file_chown 20001
file_exec 20000
file_getcontrol 20011
file_getfh 20017
file_get_fs_options 20030
file_getlinknode 20016
file_get_storage_info 20015
file_get_translator 20028
file_get_translator_cntl 20029
file_lock 20007
file_lock_stat 20008
file_notice_changes 20010
file_reparent 20031
file_set_size 20006
file_set_translator 20027
file_statfs 20012
file_sync 20013
file_syncfs 20014
file_utimes 20005
fsys_forward 22008
fsys_getfile 22003
fsys_get_options 22009
fsys_getpriv 22006
fsys_getroot 22002
fsys_goaway 22001
fsys_init 22007
fsys_set_options 22005
fsys_startup 22000
fsys_syncfs 22004
ifsock_getsockaddr 34000
interrupt_operation 33000
io_async 21008
io_clear_some_openmodes 21007
io_duplicate 21016
io_eofnotify 21022
io_get_conch 21020
io_get_icky_async_id 21011
io_get_openmodes 21005
io_get_owner 21010
io_identity 21029
io_map 21018
io_map_cntl 21019
io_mod_owner 21009
io_pathconf 21028
io_postnotify 21024
io_prenotify 21023
io_readable 21003
io_read 21001
io_readnotify 21025
io_readsleep 21026
io_reauthenticate 21014
io_release_conch 21021
io_restrict_auth 21015
io_revoke 21030
io_seek 21002
io_select 21012
io_server_version 21017
io_set_all_openmodes 21004
io_set_some_openmodes 21006
io_sigio 21027
io_stat 21013
io_write 21000
login_get_idle_time 36002
login_get_input_devices 36003
login_get_location 36001
login_get_login_collection 36004
login_message_user 36000
msg_add_auth 23002
msg_del_auth 23003
msg_describe_ports 23024
msg_get_dtable 23012
msg_get_environment 23016
msg_get_env_variable 23018
msg_get_fd 23014
msg_get_init_int 23008
msg_get_init_ints 23010
msg_get_init_port 23004
msg_get_init_ports 23006
msg_proc_newids 23001
msg_report_wait 23023
msg_set_dtable 23013
msg_set_environment 23017
msg_set_env_variable 23019
msg_set_fd 23015
msg_set_init_int 23009
msg_set_init_ints 23011
msg_set_init_port 23005
msg_set_init_ports 23007
msg_sig_post 23000
msg_sig_post_reply 23100
msg_sig_post_request 23000
msg_sig_post_untraced 23022
msg_sig_post_untraced_reply 23122
msg_sig_post_untraced_request 23022
password_check_group 38001
password_check_user 38000
proc_child 24012
proc_child_request 24012
proc_dostop 24021
proc_dostop_request 24021
proc_execdata_notify 24008
proc_execdata_notify_request 24008
proc_getallpids 24005
proc_getallpids_request 24005
proc_get_arg_locations 24018
proc_get_arg_locations_request 24018
proc_getexecdata 24007
proc_getexecdata_request 24007
proc_getlogin 24041
proc_getloginid 24038
proc_getloginid_request 24038
proc_getloginpids 24039
proc_getloginpids_request 24039
proc_getlogin_request 24041
proc_getmsgport 24019
proc_getmsgport_request 24019
proc_getpgrp 24048
proc_getpgrppids 24049
proc_getpgrppids_request 24049
proc_getpgrp_request 24048
proc_getpids 24016
proc_getpids_request 24016
proc_getprivports 24004
proc_getprivports_request 24004
proc_getprocargs 24035
proc_getprocargs_request 24035
proc_getprocenv 24036
proc_getprocenv_request 24036
proc_getprocinfo 24034
proc_getprocinfo_request 24034
proc_getsessionpgids 24044
proc_getsessionpgids_request 24044
proc_getsessionpids 24045
proc_getsessionpids_request 24045
proc_getsid 24043
proc_getsidport 24046
proc_getsidport_request 24046
proc_getsid_request 24043
proc_get_tty 24050
proc_get_tty_request 24050
proc_handle_exceptions 24022
proc_handle_exceptions_request 24022
proc_make_login_coll 24037
proc_make_login_coll_request 24037
proc_mark_cont 24024
proc_mark_cont_request 24024
proc_mark_exec 24026
proc_mark_exec_request 24026
proc_mark_exit 24025
proc_mark_exit_request 24025
proc_mark_stop 24023
proc_mark_stop_request 24023
proc_mark_traced 24027
proc_mark_traced_request 24027
proc_mod_stopchild 24028
proc_mod_stopchild_request 24028
proc_pid2proc 24033
proc_pid2proc_request 24033
proc_pid2task 24029
proc_pid2task_request 24029
proc_proc2task 24032
proc_proc2task_request 24032
proc_reassign 24014
proc_reassign_request 24014
proc_reauthenticate 24011
proc_reauthenticate_request 24011
proc_register_version 24010
proc_register_version_request 24010
proc_set_arg_locations 24017
proc_set_arg_locations_request 24017
proc_setexecdata 24006
proc_setexecdata_request 24006
proc_setlogin 24040
proc_setlogin_request 24040
proc_setmsgport 24013
proc_setmsgport_request 24013
proc_setowner 24015
proc_setowner_request 24015
proc_setpgrp 24047
proc_setpgrp_request 24047
proc_setsid 24042
proc_setsid_request 24042
proc_task2pid 24030
proc_task2pid_request 24030
proc_task2proc 24031
proc_task2proc_request 24031
proc_uname 24009
proc_uname_request 24009
proc_wait 24020
proc_wait_request 24020
socket_accept 26002
socket_bind 26004
socket_connect2 26007
socket_connect 26003
socket_create_address 26008
socket_create 26000
socket_fabricate_address 26009
socket_getopt 26012
socket_listen 26001
socket_name 26005
socket_peername 26006
socket_recv 26015
socket_send 26014
socket_setopt 26013
socket_shutdown 26011
socket_whatis_address 26010
startup_authinit 29004
startup_essential_task 29000
startup_procinit 29003
startup_reboot 29002
startup_request_notification 29001
termctty_open_terminal 28009
term_get_bottom_type 28005
term_getctty 28000
term_get_nodename 28003
term_get_peername 28010
term_on_hurddev 28007
term_on_machdev 28006
term_on_pty 28008
term_open_ctty 28001
term_set_filenode 28004
term_set_nodename 28002
tioctl_tioccbrk 156222
tioctl_tioccdtr 156220
tioctl_tiocdrain 156094
tioctl_tiocexcl 156013
tioctl_tiocext 156096
tioctl_tiocflush 156016
tioctl_tiocgeta 156019
tioctl_tiocgetd 156026
tioctl_tiocgpgrp 156219
tioctl_tiocgwinsz 156204
tioctl_tiocmbic 156207
tioctl_tiocmbis 156208
tioctl_tiocmget 156206
tioctl_tiocmodg 156003
tioctl_tiocmods 156004
tioctl_tiocmset 156209
tioctl_tiocnxcl 156014
tioctl_tiocoutq 156215
tioctl_tiocpkt 156212
tioctl_tiocremote 156205
tioctl_tiocsbrk 156223
tioctl_tiocsdtr 156221
tioctl_tiocseta 156020
tioctl_tiocsetaf 156022
tioctl_tiocsetaw 156021
tioctl_tiocsetd 156027
tioctl_tiocsig 156095
tioctl_tiocspgrp 156218
tioctl_tiocstart 156210
tioctl_tiocsti 156214
tioctl_tiocstop 156211
tioctl_tiocswinsz 156203
tioctl_tiocucntl 156202






reply via email to

[Prev in Thread] Current Thread [Next in Thread]