From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id 9CC6B384B07C for ; Wed, 6 Jul 2022 13:37:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9CC6B384B07C X-IronPort-AV: E=McAfee;i="6400,9594,10399"; a="345433886" X-IronPort-AV: E=Sophos;i="5.92,250,1650956400"; d="scan'208";a="345433886" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2022 06:37:09 -0700 X-IronPort-AV: E=Sophos;i="5.92,250,1650956400"; d="scan'208";a="650667213" Received: from sugan-001.iul.intel.com (HELO localhost) ([172.28.50.209]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2022 06:37:07 -0700 From: Ari Hannula To: gdb-patches@sourceware.org Cc: Tim Wiederhake , Ari Hannula Subject: [PATCH v3 2/2] [func_call] Add function-call-history command to MI. Date: Wed, 6 Jul 2022 15:36:39 +0200 Message-Id: <20220706133639.114681-3-ari.hannula@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220706133639.114681-1-ari.hannula@intel.com> References: <20220706133639.114681-1-ari.hannula@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2022 13:37:15 -0000 From: Tim Wiederhake This allows MI clients like Eclipse to retrieve the function call history. Changes the output of the command. Previously it returned a tuple of tuples, and now returns a list of tuples. MI response was fixed to follow MI syntax, e.g. "insn history" or "func history" -> "call-history" "insn begin" -> "insn-begin" "insn end" -> "insn-end" "min line" -> "min-line" "max line" -> "max-line" Adds documentation for the command. Adds tests for the command. Signed-off-by: Tim Wiederhake Signed-off-by: Ari Hannula --- gdb/doc/gdb.texinfo | 98 +++++++++++++++++++ gdb/mi/mi-cmd-record.c | 53 +++++++++- gdb/mi/mi-cmd-record.h | 5 + gdb/mi/mi-cmds.c | 1 + gdb/mi/mi-cmds.h | 1 + gdb/record-btrace.c | 22 +++-- gdb/record.c | 28 +++--- gdb/record.h | 18 ++++ .../gdb.mi/mi-function_call_history.exp | 95 ++++++++++++++++++ 9 files changed, 298 insertions(+), 23 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 5e7e0138a27..eb16bbbc8b6 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -37788,6 +37788,104 @@ No equivalent. (gdb) @end smallexample = +@subheading The @code{-function-call-history} Command +@findex -function-call-history + +@subheading Synopsis + +@smallexample +-function-call-history +@end smallexample + +Return the function call history in the recorded execution trace. + +@subheading Result + +The @samp{call-history} result is a list of tuples, where each tuple may h= ave +the following fields: + +@table @samp +@item index +The function number in control-flow order. + +@item level +The function level in a back trace across the entire branch trace. + +@item function +Symbol name of the function. + +@item file +Source file path and name. + +@item insn-begin +Instruction number range begin. + +@item insn-end +Instruction number range end. + +@item min-line +Source line range begin. + +@item max-line +Source line range end. + +@end table + +@subheading @value{GDBN} Command + +The corresponding @value{GDBN} command is @samp{record function-call-histo= ry}. + +@subheading Example + +@smallexample +-function-call-history +^done,call-history=3D[@{index=3D"12",function=3D"inc"@},@{index=3D"13", +function=3D"main"@},@{index=3D"14",function=3D"inc"@},@{index=3D"15",funct= ion=3D"main"@}, +@{index=3D"16",function=3D"inc"@},@{index=3D"17",function=3D"main"@},@{ind= ex=3D"18", +function=3D"inc"@},@{index=3D"19",function=3D"main"@},@{index=3D"20",funct= ion=3D"inc"@}, +@{index=3D"21",function=3D"main"@}] +(gdb) +-function-call-history 12 16 +^done,call-history=3D[@{index=3D"12",function=3D"inc"@},@{index=3D"13", +function=3D"main"@},@{index=3D"14",function=3D"inc"@},@{index=3D"15",funct= ion=3D"main"@}, +@{index=3D"16",function=3D"inc"@}] +(gdb) +-function-call-history /ilc 14 20 +^done,call-history=3D[@{index=3D"14",level=3D"1",function=3D"inc",insn-beg= in=3D"98", +insn-end=3D"105",file=3D"source.c",min-line=3D"20",max-line=3D"22"@},@{ind= ex=3D"15", +level=3D"0",function=3D"main",insn-begin=3D"106",insn-end=3D"112",file=3D"= source.c", +min-line=3D"38",max-line=3D"39"@},@{index=3D"16",level=3D"1",function=3D"i= nc", +insn-begin=3D"113",insn-end=3D"120",file=3D"source.c",min-line=3D"20",max-= line=3D"22"@}, +@{index=3D"17",level=3D"0",function=3D"main",insn-begin=3D"121",insn-end= =3D"127", +file=3D"source.c",min-line=3D"38",max-line=3D"39"@},@{index=3D"18",level= =3D"1", +function=3D"inc",insn-begin=3D"128",insn-end=3D"135",file=3D"source.c",min= -line=3D"20", +max-line=3D"22"@},@{index=3D"19",level=3D"0",function=3D"main",insn-begin= =3D"136", +insn-end=3D"142",file=3D"source.c",min-line=3D"38",max-line=3D"39"@},@{ind= ex=3D"20", +level=3D"1",function=3D"inc",insn-begin=3D"143",insn-end=3D"150",file=3D"s= ource.c", +min-line=3D"20",max-line=3D"22"@}] +(gdb) +-function-call-history /lc 1 5 +^done,call-history=3D[@{index=3D"1",level=3D"0",function=3D"main",file=3D"= source.c", +min-line=3D"38",max-line=3D"39"@},@{index=3D"2",level=3D"1",function=3D"in= c", +file=3D"source.c",min-line=3D"20",max-line=3D"22"@},@{index=3D"3",level=3D= "0", +function=3D"main",file=3D"source.c",min-line=3D"38",max-line=3D"39"@}] +(gdb) +-function-call-history /l 1 5 +^done,call-history=3D[@{index=3D"1",function=3D"main",file=3D"source.c",mi= n-line=3D"38", +max-line=3D"39"@},@{index=3D"2",function=3D"inc",file=3D"source.c",min-lin= e=3D"20", +max-line=3D"22"@},@{index=3D"3",function=3D"main",file=3D"source.c",min-li= ne=3D"38", +max-line=3D"39"@},@{index=3D"4",function=3D"inc",file=3D"source.c",min-lin= e=3D"20", +max-line=3D"22"@},@{index=3D"5",function=3D"main",file=3D"source.c",min-li= ne=3D"38", +max-line=3D"39"@}] +(gdb) +-function-call-history /c 1 5 +^done,call-history=3D[@{index=3D"1",level=3D"0",function=3D"main"@},@{inde= x=3D"2", +level=3D"1",function=3D"inc"@},@{index=3D"3",level=3D"0",function=3D"main"= @},@{index=3D"4", +level=3D"1",function=3D"inc"@},@{index=3D"5",level=3D"0",function=3D"main"= @}] +(gdb) + +@end smallexample + @node Annotations @chapter @value{GDBN} Annotations = diff --git a/gdb/mi/mi-cmd-record.c b/gdb/mi/mi-cmd-record.c index 7c5019e2616..6416a59b87b 100644 --- a/gdb/mi/mi-cmd-record.c +++ b/gdb/mi/mi-cmd-record.c @@ -15,9 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . = */ = - #include "defs.h" #include "target.h" +#include "record.h" #include "mi-cmd-record.h" #include "mi-out.h" = @@ -32,3 +32,54 @@ mi_cmd_record_function_call_history_length (const char *= command, ui_out *uiout =3D current_uiout; uiout->field_unsigned ("length", target_call_history_length ()); } + +void +mi_cmd_record_function_call_history (const char *command, char **argv, + int argc) +{ + record_print_flags flags =3D 0; + unsigned int low, high; + char *charend; + + if (argc < 0 || argc > 3) + error (_("-function-call-history: Invalid number of arguments.")); + + require_record_target (); + + if (argc =3D=3D 1 || argc =3D=3D 3) + { + const char *targv =3D argv[0]; + flags =3D get_call_history_modifiers (&targv); + } + + if (argc =3D=3D 0 || argc =3D=3D 1) + { + const int size + =3D command_size_to_target_size (get_record_call_history_size ()); + target_call_history (size, flags); + return; + } + + if (argc =3D=3D 3) + { + low =3D strtoul (argv[1], &charend, 10); + if (*charend !=3D '\0') + error (_("Invalid syntax of begin func id '%s'"), argv[1]); + + high =3D strtoul (argv[2], &charend, 10); + if (*charend !=3D '\0') + error (_("Invalid syntax of end func id '%s'"), argv[2]); + } + else + { + low =3D strtoul (argv[0], &charend, 10); + if (*charend !=3D '\0') + error (_("Invalid syntax of begin func id '%s'"), argv[0]); + + high =3D strtoul (argv[1], &charend, 10); + if (*charend !=3D '\0') + error (_("Invalid syntax of end func id '%s'"), argv[1]); + } + + target_call_history_range (low, high, flags); +} diff --git a/gdb/mi/mi-cmd-record.h b/gdb/mi/mi-cmd-record.h index fbd5052dba6..da2f15fc8b3 100644 --- a/gdb/mi/mi-cmd-record.h +++ b/gdb/mi/mi-cmd-record.h @@ -24,4 +24,9 @@ extern void mi_cmd_record_function_call_history_length (c= onst char *, char **, int); = +/* The MI version of the command to get the function call history for + record targets. */ +extern void mi_cmd_record_function_call_history (const char *, char **, + int); + #endif /* MI_MI_CMD_RECORD_H */ diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c index 45a5692ff52..c40cdb5d6d9 100644 --- a/gdb/mi/mi-cmds.c +++ b/gdb/mi/mi-cmds.c @@ -286,6 +286,7 @@ add_builtin_mi_commands () mi_cmd_fix_multi_location_breakpoint_output), add_mi_cmd_mi ("function-call-history-length", mi_cmd_record_function_call_history_length); + add_mi_cmd_mi ("function-call-history", mi_cmd_record_function_call_hist= ory); add_mi_cmd_mi ("gdb-exit", mi_cmd_gdb_exit); add_mi_cmd_cli ("gdb-set", "set", 1, &mi_suppress_notification.cmd_param_changed); diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h index ba990cf871b..534d3908138 100644 --- a/gdb/mi/mi-cmds.h +++ b/gdb/mi/mi-cmds.h @@ -91,6 +91,7 @@ extern mi_cmd_argv_ftype mi_cmd_list_features; extern mi_cmd_argv_ftype mi_cmd_list_target_features; extern mi_cmd_argv_ftype mi_cmd_list_thread_groups; extern mi_cmd_argv_ftype mi_cmd_record_function_call_history_length; +extern mi_cmd_argv_ftype mi_cmd_record_function_call_history; extern mi_cmd_argv_ftype mi_cmd_remove_inferior; extern mi_cmd_argv_ftype mi_cmd_stack_info_depth; extern mi_cmd_argv_ftype mi_cmd_stack_info_frame; diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index f2f70fad9c5..0f894c68172 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -1043,9 +1043,9 @@ btrace_call_history_insn_range (struct ui_out *uiout, begin =3D bfun->insn_offset; end =3D begin + size - 1; = - uiout->field_unsigned ("insn begin", begin); + uiout->field_unsigned ("insn-begin", begin); uiout->text (","); - uiout->field_unsigned ("insn end", end); + uiout->field_unsigned ("insn-end", end); } = /* Compute the lowest and highest source line for the instructions in BFUN @@ -1109,13 +1109,13 @@ btrace_call_history_src_line (struct ui_out *uiout, return; = uiout->text (":"); - uiout->field_signed ("min line", begin); + uiout->field_signed ("min-line", begin); = if (end =3D=3D begin) return; = uiout->text (","); - uiout->field_signed ("max line", end); + uiout->field_signed ("max-line", end); } = /* Get the name of a branch trace function. */ @@ -1157,6 +1157,7 @@ btrace_call_history (struct ui_out *uiout, = for (it =3D *begin; btrace_call_cmp (&it, end) < 0; btrace_call_next (&i= t, 1)) { + ui_out_emit_tuple tuple_emitter (uiout, nullptr); const struct btrace_function *bfun; struct minimal_symbol *msym; struct symbol *sym; @@ -1186,10 +1187,13 @@ btrace_call_history (struct ui_out *uiout, = if ((flags & RECORD_PRINT_INDENT_CALLS) !=3D 0) { - int level =3D bfun->level + btinfo->level, i; + const int level =3D bfun->level + btinfo->level; = - for (i =3D 0; i < level; ++i) - uiout->text (" "); + if (uiout->is_mi_like_p ()) + uiout->field_signed ("level", level); + else + for (int i =3D 0; i < level; ++i) + uiout->text (" "); } = if (sym !=3D NULL) @@ -1241,7 +1245,7 @@ record_btrace_target::call_history (int size, record_= print_flags flags) unsigned int context, covered; = uiout =3D current_uiout; - ui_out_emit_tuple tuple_emitter (uiout, "insn history"); + ui_out_emit_list list_emitter (uiout, "call-history"); context =3D abs (size); if (context =3D=3D 0) error (_("Bad record function-call-history-size.")); @@ -1328,7 +1332,7 @@ record_btrace_target::call_history_range (ULONGEST fr= om, ULONGEST to, int found; = uiout =3D current_uiout; - ui_out_emit_tuple tuple_emitter (uiout, "func history"); + ui_out_emit_list list_emitter (uiout, "call-history"); low =3D from; high =3D to; = diff --git a/gdb/record.c b/gdb/record.c index 17a5df262bd..c4fed25f2f2 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -65,10 +65,10 @@ find_record_target (void) return find_target_at (record_stratum); } = -/* Check that recording is active. Throw an error, if it isn't. */ +/* See record.h. */ = -static struct target_ops * -require_record_target (void) +target_ops * +require_record_target () { struct target_ops *t; = @@ -514,15 +514,9 @@ get_insn_history_modifiers (const char **arg) return modifiers; } = -/* The "set record instruction-history-size / set record - function-call-history-size" commands are unsigned, with UINT_MAX - meaning unlimited. The target interfaces works with signed int - though, to indicate direction, so map "unlimited" to INT_MAX, which - is about the same as unlimited in practice. If the user does have - a log that huge, she can fetch it in chunks across several requests, - but she'll likely have other problems first... */ +/* See record.h. */ = -static int +int command_size_to_target_size (unsigned int size) { gdb_assert (size <=3D INT_MAX || size =3D=3D UINT_MAX); @@ -596,9 +590,9 @@ cmd_record_insn_history (const char *arg, int from_tty) } } = -/* Read function-call-history modifiers from an argument string. */ +/* See record.h. */ = -static record_print_flags +record_print_flags get_call_history_modifiers (const char **arg) { record_print_flags modifiers =3D 0; @@ -755,6 +749,14 @@ set_record_call_history_size (const char *args, int fr= om_tty, &record_call_history_size); } = +/* See record.h. */ + +unsigned int +get_record_call_history_size () +{ + return record_call_history_size; +} + void _initialize_record (); void _initialize_record () diff --git a/gdb/record.h b/gdb/record.h index 0fbca9d44ce..b142ef22a47 100644 --- a/gdb/record.h +++ b/gdb/record.h @@ -102,6 +102,24 @@ extern void record_kill (struct target_ops *); Returns NULL if none is found. */ extern struct target_ops *find_record_target (void); = +/* Check that recording is active. Throw an error, if it isn't. */ +extern target_ops *require_record_target (); + +/* The "set record instruction-history-size / set record + function-call-history-size" commands are unsigned, with UINT_MAX + meaning unlimited. The target interfaces works with signed int + though, to indicate direction, so map "unlimited" to INT_MAX, which + is about the same as unlimited in practice. If the user does have + a log that huge, she can fetch it in chunks across several requests, + but she'll likely have other problems first... */ +extern int command_size_to_target_size (unsigned int); + +/* Read function-call-history modifiers from an argument string. */ +extern record_print_flags get_call_history_modifiers (const char **); + +/* Returns value of record_call_history_size. */ +extern unsigned int get_record_call_history_size (); + /* This is to be called by record_stratum targets' open routine before it does anything. */ extern void record_preopen (void); diff --git a/gdb/testsuite/gdb.mi/mi-function_call_history.exp b/gdb/testsu= ite/gdb.mi/mi-function_call_history.exp index c839f4d35d1..8d5b91c8ac4 100644 --- a/gdb/testsuite/gdb.mi/mi-function_call_history.exp +++ b/gdb/testsuite/gdb.mi/mi-function_call_history.exp @@ -70,10 +70,57 @@ mi_send_resuming_command "exec-continue" "continue to b= p.1" mi_expect_stop "breakpoint-hit" "main" ".*" "$testfile.c" 41 \ {"" "disp=3D\".*\"" } "run to breakpoint bp.1" = +mi_gdb_test "121-function-call-history" \ + "121\\^done,call-history=3D\\\[\{index=3D\"12\",function=3D\"inc\"\},\= {index=3D\"13\",function=3D\"main\"\},\{index=3D\"14\",function=3D\"inc\"\}= ,\{index=3D\"15\",function=3D\"main\"\},\{index=3D\"16\",function=3D\"inc\"= \},\{index=3D\"17\",function=3D\"main\"\},\{index=3D\"18\",function=3D\"inc= \"\},\{index=3D\"19\",function=3D\"main\"\},\{index=3D\"20\",function=3D\"i= nc\"\},\{index=3D\"21\",function=3D\"main\"\}\\\]" \ + "121 function call history default without flags" + +send_gdb "122-function-call-history\n" +gdb_expect { + -re "\"At the end of the branch trace record..*\\^done,call-history=3D= [].*$mi_gdb_prompt$" { + #Done + } + default { + perror "122 Function call history failed" + return -1 + } +} + +mi_gdb_test "123-function-call-history 12 16" \ + "123\\^done,call-history=3D\\\[\{index=3D\"12\",function=3D\"inc\"\},\= {index=3D\"13\",function=3D\"main\"\},\{index=3D\"14\",function=3D\"inc\"\}= ,\{index=3D\"15\",function=3D\"main\"\},\{index=3D\"16\",function=3D\"inc\"= \}\\\]" \ + "123 function call history range without flags" + +mi_gdb_test "124-function-call-history 12 13" \ + "124\\^done,call-history=3D\\\[\{index=3D\"12\",function=3D\"inc\"\},\= {index=3D\"13\",function=3D\"main\"\}\\\]" \ + "124 function call history range without flags" + mi_gdb_test "125-function-call-history-length" \ "125\\^done,length=3D\"21\"" \ "125 function call history length" = +mi_gdb_test "126-function-call-history 22 23" \ + "126\\^error,msg=3D\"Range out of bounds.\"" \ + "126 function call history range error check" + +mi_gdb_test "127-function-call-history /lc" \ + "127\\^done,call-history=3D\\\[\{index=3D\"14\",level=3D\"1\",function= =3D\"inc\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\= ",max-line=3D\"${decimal}\"\},\{index=3D\"15\",level=3D\"0\",function=3D\"m= ain\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max= -line=3D\"${decimal}\"\},\{index=3D\"16\",level=3D\"1\",function=3D\"inc\"\= ,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line= =3D\"${decimal}\"\},\{index=3D\"17\",level=3D\"0\",function=3D\"main\"\,fil= e=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"= ${decimal}\"\},\{index=3D\"18\",level=3D\"1\",function=3D\"inc\"\,file=3D\"= $srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${deci= mal}\"\},\{index=3D\"19\",level=3D\"0\",function=3D\"main\"\,file=3D\"$srcd= ir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\= "\},\{index=3D\"20\",level=3D\"1\",function=3D\"inc\"\,file=3D\"$srcdir/$su= bdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\"\},\{= index=3D\"21\",level=3D\"0\",function=3D\"main\",file=3D\"$srcdir/$subdir/$= testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\"\}\\\]" \ + "127 function call history default with flags" + +mi_gdb_test "128-function-call-history /ilc 14 20" \ + "128\\^done,call-history=3D\\\[\{index=3D\"14\",level=3D\"1\",function= =3D\"inc\"\,insn-begin=3D\"${decimal}\",insn-end=3D\"${decimal}\"\,file=3D\= "$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${dec= imal}\"},\{index=3D\"15\",level=3D\"0\",function=3D\"main\"\,insn-begin=3D\= "${decimal}\",insn-end=3D\"${decimal}\"\,file=3D\"$srcdir/$subdir/$testfile= .c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\"\},\{index=3D\"16\"= ,level=3D\"1\",function=3D\"inc\"\,insn-begin=3D\"${decimal}\",insn-end=3D\= "${decimal}\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decima= l}\",max-line=3D\"${decimal}\"\},\{index=3D\"17\",level=3D\"0\",function=3D= \"main\"\,insn-begin=3D\"${decimal}\",insn-end=3D\"${decimal}\"\,file=3D\"$= srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decim= al}\"\},\{index=3D\"18\",level=3D\"1\",function=3D\"inc\"\,insn-begin=3D\"$= {decimal}\",insn-end=3D\"${decimal}\"\,file=3D\"$srcdir/$subdir/$testfile.c= \",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\"\},\{index=3D\"19\",l= evel=3D\"0\",function=3D\"main\"\,insn-begin=3D\"${decimal}\",insn-end=3D\"= ${decimal}\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal= }\",max-line=3D\"${decimal}\"\},\{index=3D\"20\",level=3D\"1\",function=3D\= "inc\"\,insn-begin=3D\"${decimal}\",insn-end=3D\"${decimal}\"\,file=3D\"$sr= cdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal= }\"\}\\\]" \ + "128 function call history range with flags" + +mi_gdb_test "129-function-call-history /lc 1 5" \ + "129\\^done,call-history=3D\\\[\{index=3D\"1\",level=3D\"0\",function= =3D\"main\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}= \",max-line=3D\"${decimal}\"\},\{index=3D\"2\",level=3D\"1\",function=3D\"i= nc\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-= line=3D\"${decimal}\"\},\{index=3D\"3\",level=3D\"0\",function=3D\"main\"\,= file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line= =3D\"${decimal}\"\},\{index=3D\"4\",level=3D\"1\",function=3D\"inc\"\,file= =3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"$= {decimal}\"\},\{index=3D\"5\",level=3D\"0\",function=3D\"main\"\,file=3D\"$= srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decim= al}\"\}\\\]" \ + "129 function call history range with flags" + +mi_gdb_test "130-function-call-history /l 1 5" \ + "130\\^done,call-history=3D\\\[\{index=3D\"1\",function=3D\"main\"\,fi= le=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\= "${decimal}\"\},\{index=3D\"2\",function=3D\"inc\"\,file=3D\"$srcdir/$subdi= r/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\"\},\{ind= ex=3D\"3\",function=3D\"main\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-= line=3D\"${decimal}\",max-line=3D\"${decimal}\"\},\{index=3D\"4\",function= =3D\"inc\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\= ",max-line=3D\"${decimal}\"\},\{index=3D\"5\",function=3D\"main\"\,file=3D\= "$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${dec= imal}\"\}\\\]" \ + "130 function call history range with flags" + +mi_gdb_test "131-function-call-history /c 1 5" \ + "131\\^done,call-history=3D\\\[\{index=3D\"1\",level=3D\"0\",function= =3D\"main\"\},\{index=3D\"2\",level=3D\"1\",function=3D\"inc\"\},\{index=3D= \"3\",level=3D\"0\",function=3D\"main\"\},\{index=3D\"4\",level=3D\"1\",fun= ction=3D\"inc\"\},\{index=3D\"5\",level=3D\"0\",function=3D\"main\"\}\\\]" \ + "131 function call history range with flags" + mi_create_breakpoint "-t $testfile.c:42" "insert temp breakpoint at $testf= ile.c:42" \ -number 3 -disp del -func main -file "$srcdir/$subdir/$testfile.c" -li= ne 42 = @@ -82,8 +129,56 @@ mi_send_resuming_command "exec-continue" "continue to b= p.2" mi_expect_stop "breakpoint-hit" "main" ".*" "$testfile.c" 42 \ {"" "disp=3D\".*\"" } "run to breakpoint bp.2" = +mi_gdb_test "221-function-call-history" \ + "221\\^done,call-history=3D\\\[\{index=3D\"366\",function=3D\"fib\"\},= \{index=3D\"367\",function=3D\"fib\"\},\{index=3D\"368\",function=3D\"fib\"= \},\{index=3D\"369\",function=3D\"fib\"\},\{index=3D\"370\",function=3D\"fi= b\"\},\{index=3D\"371\",function=3D\"fib\"\},\{index=3D\"372\",function=3D\= "fib\"\},\{index=3D\"373\",function=3D\"fib\"\},\{index=3D\"374\",function= =3D\"fib\"\},\{index=3D\"375\",function=3D\"main\"\}\\\]" \ + "221 function call history default without flags" + +send_gdb "222-function-call-history\n" + +gdb_expect { + -re "\"At the end of the branch trace record..*\\^done,call-history=3D= [].*$mi_gdb_prompt$" { + #Done + } + default { + perror "222 Function call history failed" + return -1 + } +} + +mi_gdb_test "223-function-call-history 12 16" \ + "223\\^done,call-history=3D\\\[\{index=3D\"12\",function=3D\"inc\"\},\= {index=3D\"13\",function=3D\"main\"\},\{index=3D\"14\",function=3D\"inc\"\}= ,\{index=3D\"15\",function=3D\"main\"\},\{index=3D\"16\",function=3D\"inc\"= \}\\\]" \ + "223 function call history range without flags" + +mi_gdb_test "224-function-call-history 366 368" \ + "224\\^done,call-history=3D\\\[\{index=3D\"366\",function=3D\"fib\"\},= \{index=3D\"367\",function=3D\"fib\"\},\{index=3D\"368\",function=3D\"fib\"= \}\\\]" \ + "224 function call history range without flags" + mi_gdb_test "225-function-call-history-length" \ "225\\^done,length=3D\"375\"" \ "225 function call history length" = +mi_gdb_test "226-function-call-history 376 400" \ + "226\\^error,msg=3D\"Range out of bounds.\"" \ + "226 function call history range error check" + +mi_gdb_test "227-function-call-history /lc" \ + "227\\^done,call-history=3D\\\[\{index=3D\"369\",level=3D\"6\",functio= n=3D\"fib\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}= \",max-line=3D\"${decimal}\"\},\{index=3D\"370\",level=3D\"5\",function=3D\= "fib\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",ma= x-line=3D\"${decimal}\"\},\{index=3D\"371\",level=3D\"4\",function=3D\"fib\= "\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-lin= e=3D\"${decimal}\"\},\{index=3D\"372\",level=3D\"3\",function=3D\"fib\"\,fi= le=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\= "${decimal}\"\},\{index=3D\"373\",level=3D\"2\",function=3D\"fib\"\,file=3D= \"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${de= cimal}\"\},\{index=3D\"374\",level=3D\"1\",function=3D\"fib\"\,file=3D\"$sr= cdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal= }\"\},\{index=3D\"375\",level=3D\"0\",function=3D\"main\"\,file=3D\"$srcdir= /$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\"\= }\\\]" \ + "227 function call history default with flags" + +mi_gdb_test "228-function-call-history /lc 14 20" \ + "228\\^done,call-history=3D\\\[\{index=3D\"14\",level=3D\"1\",function= =3D\"inc\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\= ",max-line=3D\"${decimal}\"\},\{index=3D\"15\",level=3D\"0\",function=3D\"m= ain\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max= -line=3D\"${decimal}\"\},\{index=3D\"16\",level=3D\"1\",function=3D\"inc\"\= ,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line= =3D\"${decimal}\"\},\{index=3D\"17\",level=3D\"0\",function=3D\"main\"\,fil= e=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"= ${decimal}\"\},\{index=3D\"18\",level=3D\"1\",function=3D\"inc\"\,file=3D\"= $srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${deci= mal}\"\},\{index=3D\"19\",level=3D\"0\",function=3D\"main\"\,file=3D\"$srcd= ir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\= "\},\{index=3D\"20\",level=3D\"1\",function=3D\"inc\"\,file=3D\"$srcdir/$su= bdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\"\}\\\= ]" \ + "228 function call history range with flags" + +mi_gdb_test "229-function-call-history /lc 1 5" \ + "229\\^done,call-history=3D\\\[\{index=3D\"1\",level=3D\"0\",function= =3D\"main\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}= \",max-line=3D\"${decimal}\"\},\{index=3D\"2\",level=3D\"1\",function=3D\"i= nc\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-= line=3D\"${decimal}\"\},\{index=3D\"3\",level=3D\"0\",function=3D\"main\"\,= file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line= =3D\"${decimal}\"\},\{index=3D\"4\",level=3D\"1\",function=3D\"inc\"\,file= =3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"$= {decimal}\"\},\{index=3D\"5\",level=3D\"0\",function=3D\"main\"\,file=3D\"$= srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decim= al}\"\}\\\]" \ + "229 function call history range with flags" + +mi_gdb_test "230-function-call-history /l 1 5" \ + "230\\^done,call-history=3D\\\[\{index=3D\"1\",function=3D\"main\"\,fi= le=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\= "${decimal}\"\},\{index=3D\"2\",function=3D\"inc\"\,file=3D\"$srcdir/$subdi= r/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${decimal}\"\},\{ind= ex=3D\"3\",function=3D\"main\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-= line=3D\"${decimal}\",max-line=3D\"${decimal}\"\},\{index=3D\"4\",function= =3D\"inc\"\,file=3D\"$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\= ",max-line=3D\"${decimal}\"\},\{index=3D\"5\",function=3D\"main\"\,file=3D\= "$srcdir/$subdir/$testfile.c\",min-line=3D\"${decimal}\",max-line=3D\"${dec= imal}\"\}\\\]" \ + "230 function call history range with flags" + +mi_gdb_test "231-function-call-history /c 1 5" \ + "231\\^done,call-history=3D\\\[\{index=3D\"1\",level=3D\"0\",function= =3D\"main\"\},\{index=3D\"2\",level=3D\"1\",function=3D\"inc\"\},\{index=3D= \"3\",level=3D\"0\",function=3D\"main\"\},\{index=3D\"4\",level=3D\"1\",fun= ction=3D\"inc\"\},\{index=3D\"5\",level=3D\"0\",function=3D\"main\"\}\\\]" \ + "231 function call history range with flags" + mi_gdb_exit -- = 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928