[xmon PATCH 1/1] RFC: Add xmon command to dump process/task similar to ps(1)

Douglas Miller dougmill at linux.vnet.ibm.com
Sat Nov 14 02:58:19 AEDT 2015


Thanks, Ben, for the feedback.

Here is an updated patch. I added a macro XMON_PROTECT() to wrap a 
statement in what I think is the correct setjmp/protection code. Each 
place seems to do it slightly differently, so I wasn't sure what the 
right way was and didn't want to change all other places until we were 
certain. If you have a better way to implement this, please let me know. 
It may be difficult to make a macro that fits all use cases, too.

I checked using a task point of NULL and it errored out safely, and also 
tried a pointer to valid memory but not a valid task_struct and it also 
errored out cleanly. Of course, random memory might not always cause a 
fault but rather just print garbage.

Thanks,
Doug

On 11/11/2015 02:09 AM, Benjamin Herrenschmidt wrote:
> On Tue, 2015-11-10 at 10:50 -0600, Douglas Miller wrote:
>> +{
>> +	unsigned long tskv;
>> +	struct task_struct *tsk;
>> +
>> +	if (scanhex(&tskv)) {
>> +		procshow((struct task_struct *)tskv);
>> +	} else {
>> +		for_each_process(tsk) {
>> +			procshow(tsk);
>> +		}
>> +	}
>> +}
>> +
> The main thing is wrap it with the setjump magic that xmon uses for
> other things that allows it to recover if you hit a bad pointer
> along the way:
>
> 	if (setjmp(bus_error_jmp) == 0) {
> 		catch_memory_errors = 1;
> 		sync();
> 		... do your stuff...
> 		sync();
> 	}
> 	catch_memory_errors = 0;
>
> We could make some kind of helper or macro to factor that out
> while it it ;-) (For bonus points !)
>
> Cheers,
> Ben.
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-xmon-command-to-dump-process-task-similar-to-ps-.patch
Type: text/x-patch
Size: 2937 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20151113/85956138/attachment.bin>


More information about the Linuxppc-dev mailing list