Skip to content

Commit

Permalink
Add stack overflow prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
nicovank committed Mar 20, 2024
1 parent 8b3c3a1 commit 90f6fb7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/chatdbg/chatdbg_lldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def get_frame_summaries(
summaries.pop(-2)

total_summary_count = sum(
[1 if isinstance(s, _FrameSummaryEntry) else s.count() for s in summaries]
[s.count() if isinstance(s, _SkippedFramesEntry) else 1 for s in summaries]
)

if total_summary_count < len(thread):
Expand All @@ -675,7 +675,7 @@ def get_frame_summaries(
summaries.pop(-2)

assert sum(
[1 if isinstance(s, _FrameSummaryEntry) else s.count() for s in summaries]
[s.count() if isinstance(s, _SkippedFramesEntry) else 1 for s in summaries]
) == len(thread)

return summaries
Expand Down Expand Up @@ -751,7 +751,7 @@ def chat(

summaries = get_frame_summaries(debugger)
if not summaries:
result.AppendWarning("could not generate a frame summary.")
result.AppendWarning("could not generate any frame summary.")
else:
frame_summary = "\n".join([str(s) for s in summaries])
parts.append(
Expand All @@ -760,6 +760,18 @@ def chat(
+ "\n```"
)

total_frames = sum(
[
s.count() if isinstance(s, _SkippedFramesEntry) else 1
for s in summaries
]
)

if total_frames > 1000:
parts.append(
"Note that there are over 1000 frames in the stack trace, hinting at a possible stack overflow error."
)

max_initial_locations_to_send = 3
source_code_entries = []
for summary in summaries:
Expand Down

0 comments on commit 90f6fb7

Please sign in to comment.