This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add extra 'info os' information types for Linux


Sorry for the late reply - I was busy on another project.

On 21/10/2011 9:57 PM, Tom Tromey wrote:
+static int
+compare_processes (const void *process1, const void *process2)

Most of the new functions need introductory comments.



I've now commented all the auxilliary functions used by the linux_xfer_osdata_<data type> functions.


+ static struct buffer buffer;

Wow, another growable buffer type. I didn't know about this one. Let's see.. VEC, dynstr, obstack, buffer... can we have a 5th? :)


buffer was used in the gdbserver implementation of Linux osdata, while obstacks were used in the gdb implementation. When combining the two, I went with buffer since it was self-contained in GDB (it is implemented in gdb/common/buffer.[hc]).


+ char procentry[sizeof ("/proc/4294967295")];

One occasionally hears talk of 64 bit PIDs.


+static void
+time_from_int (char *time, int maxlen, int seconds)

Why int and not just time_t? ...

+		  items_read = sscanf (buf,
+				       "%d %d %o %d %d %d %d %u %u %u %u %d %d %d",
+				&key,&shmid,&perms,&size,
+				&cpid,&lpid,
+				&nattch,
+				&uid,&gid,&cuid,&cgid,
+				&atime,&dtime,&ctime);
[...]
+ char atime_str[32], dtime_str[32], ctime_str[32];
[...]
+		      time_from_int (atime_str, sizeof (atime_str), atime);
+		      time_from_int (dtime_str, sizeof (dtime_str), dtime);
+		      time_from_int (ctime_str, sizeof (ctime_str), ctime);

I think it is probably better to use long at least.



I have worked around the issue of the sizes of time_t and pid_t by defining my own local versions (TIME_T and PID_T) which are of a known type. The code in linux-osdata.c works with these types and cast to/from time_t/pid_t when calling external functions. I have also changed buffer_xml_printf to be able to handle long and long long format specifiers in the format string.


>>> +#if 0
>>> +			  struct stat statbuf;
>>> +			  stat (dp2->d_name,&statbuf);
>>> +#endif
>
> No new #if 0 code.
>

Now removed.

Kwok


ChangeLog:


gdb/
	* common/linux-osdata.c (PID_T, TIME_T): Add local versions of pid_t and
	time_t to avoid problems with the size of the native versions.
	(MAX_PID_T_STRLEN): New.
	(linux_common_core_of_thread): Add comment.  Change to use PID_T and
	MAX_PID_T_STRLEN.
	(command_from_pid): Add comment.  Change to use PID_T.
	(commandline_from_pid):  Change to use PID_T.
	(user_from_pid): Add comment.
	(get_process_owner): Add comment. Change to use PID_T and
	MAX_PID_T_STRLEN.
	(get_number_of_cpu_cores): Add comment.
	(get_cores_used_by_process): Add comment.  Change to use PID_T and
	MAX_PID_T_STRLEN.
	(linux_xfer_osdata_processes): Change to use PID_T and MAX_PID_T_STRLEN.
	(compare_processes): Auxiliary function for
	linux_xfer_osdata_processgroups.
	(linux_xfer_osdata_processgroups): New function to
	look up process groups.
	(linux_xfer_osdata_threads): Change to use PID_T.
	(linux_xfer_osdata_fds): New function to look up file descriptors.
	(format_socket_state, print_sockets): Auxiliary functions for
	linux_xfer_osdata_isockets.
	(union socket_addr): New union used to avoid strict-aliasing problems.
	(linux_xfer_osdata_isockets): New function to look up internet sockets.
	(time_from_time_t, group_from_gid): New convenience functions for
	converting between data types.	
	(linux_xfer_osdata_shm): New function to look up shared memory for IPC.
	(linux_xfer_osdata_sem): New function to look up semaphores for IPC.
	(linux_xfer_osdata_msg): New function to look up message queues for
	IPC.
	(linux_xfer_osdata_modules): New function to look up loaded kernel
	modules.
	(osdata_table): Add new entries.
	* common/buffer.c (buffer_xml_printf): Add support for long and
	long long format specifiers.

Attachment: os-awareness_2.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]