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 includeln argument which includes method line number to frame #8

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ Error Arguments::parse(const char* args) {
CASE("includemm")
_includemm = true;

CASE("includeln")
_includeln = true;

DEFAULT()
if (_unknown_arg == NULL) _unknown_arg = arg;
}
Expand Down
4 changes: 3 additions & 1 deletion src/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class Arguments {
bool _live;
bool _fdtransfer;
bool _includemm;
bool _includeln;
const char* _fdtransfer_path;
int _style;
CStack _cstack;
Expand Down Expand Up @@ -235,7 +236,8 @@ class Arguments {
_minwidth(0),
_reverse(false),
_log_meminfo_on_dump(false),
_includemm(false) {
_includemm(false),
_includeln(false) {
}

~Arguments();
Expand Down
10 changes: 10 additions & 0 deletions src/frameName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ FrameName::FrameName(Arguments& args, int style, int epoch, Mutex& thread_names_
// Require printf to use standard C format regardless of system locale
_saved_locale = uselocale(newlocale(LC_NUMERIC_MASK, "C", (locale_t)0));
_includemm = args._includemm;
_includeln = args._includeln;
buildFilter(_include, args._buf, args._include);
buildFilter(_exclude, args._buf, args._exclude);

Expand Down Expand Up @@ -185,6 +186,8 @@ void FrameName::javaMethodName(jmethodID method) {
char* class_name = NULL;
char* method_name = NULL;
char* method_sig = NULL;
jvmtiLineNumberEntry* line_number_table = NULL;
jint entry_count = 0;
jint modifiers = 0;

jvmtiEnv* jvmti = VM::jvmti();
Expand All @@ -206,6 +209,13 @@ void FrameName::javaMethodName(jmethodID method) {
_str.insert(0, modifiers_to_append);
}
_str.append(".").append(method_name);
if (_includeln) {
if (jvmti->GetLineNumberTable(method, &entry_count, &line_number_table) == 0) {
char buf[32];
sprintf(buf, ":%d", line_number_table[0].line_number);
_str.append(buf);
}
}
if (_style & STYLE_SIGNATURES) {
if (_style & STYLE_NO_SEMICOLON) {
for (char* s = method_sig; *s; s++) {
Expand Down
1 change: 1 addition & 0 deletions src/frameName.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class FrameName {
ThreadMap& _thread_names;
locale_t _saved_locale;
bool _includemm;
bool _includeln;

void buildFilter(std::vector<Matcher>& vector, const char* base, int offset);
const char* decodeNativeSymbol(const char* name);
Expand Down