Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MAT threads and jstack -F #4

Open
mgm3746 opened this issue Mar 10, 2022 · 0 comments
Open

Add support for MAT threads and jstack -F #4

mgm3746 opened this issue Mar 10, 2022 · 0 comments

Comments

@mgm3746
Copy link

mgm3746 commented Mar 10, 2022

Add support for Eclipse MAT thread and jstack -F output.

For example:
$ sh ./yatda.sh --mat -f heap.hprof.threads
$ sh ./yatda.sh --forced -f jstack-F.out

I didn't add any logic for --mat or --forced, but it looks like both could be handled with these changes, at least for the basic "Top lines of all threads" and "Most common from first 10 lines of all threads":

$ diff yatda.sh yatda-mat-jstack-F.sh 
15,16c15,16
< DUMP_NAME="Full thread dump "
< ALL_THREAD_NAME=" nid=0x"
---
> DUMP_NAME="(Full thread dump |Attaching to process ID )"
> ALL_THREAD_NAME="( nid=0x|Thread [[:digit:]])"
45c45
< DUMP_COUNT=`grep "$DUMP_NAME" $FILE_NAME | wc -l`
< echo "Number of thread dumps: " $DUMP_COUNT > $FILE_NAME.yatda
< 
< THREAD_COUNT=`grep "$ALL_THREAD_NAME" $FILE_NAME | wc -l`
---
> DUMP_COUNT=`grep -E "$DUMP_NAME" $FILE_NAME | wc -l`
> THREAD_COUNT=`grep -E "$ALL_THREAD_NAME" $FILE_NAME | wc -l`
> if [ `expr $DUMP_COUNT` == 0 ]; then
>     if [ $THREAD_COUNT -gt 0 ]; then
>         # MAT thread output 
>         echo "Number of thread dumps: 1" > $FILE_NAME.yatda
>     fi
> else
>     echo "Number of thread dumps: " $DUMP_COUNT > $FILE_NAME.yatda
> fi
211c217,218
< grep "$ALL_THREAD_NAME" -A 2 $FILE_NAME | grep "at " | sort | uniq -c | sort -nr >> $FILE_NAME.yatda
---
> #grep "$ALL_THREAD_NAME" -A 2 $FILE_NAME | grep "at " | sort | uniq -c | sort -nr >> $FILE_NAME.yatda
> grep -E "$ALL_THREAD_NAME" -A 1 $FILE_NAME | grep -E "(at |- )" | sort | uniq -c | sort -nr >> $FILE_NAME.yatda
216c223,224
< grep "$ALL_THREAD_NAME" -A `expr $ALL_LINE_COUNT + 1` $FILE_NAME | grep "at " | sort | uniq -c | sort -nr >> $FILE_NAME.yatda
---
> #grep "$ALL_THREAD_NAME" -A `expr $ALL_LINE_COUNT + 1` $FILE_NAME | grep "at " | sort | uniq -c | sort -nr >> $FILE_NAME.yatda
> grep -E "$ALL_THREAD_NAME" -A `expr $ALL_LINE_COUNT + 1` $FILE_NAME | grep -E "(at |- )" | sort | uniq -c | sort -nr >> $FILE_NAME.yatda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant