Skip to content

Commit 87df91b

Browse files
committed
Added the ability to restrict breakpoints by function name, function regexp, selector
etc to specific source files. Added SB API's to specify these source files & also more than one module. Added an "exact" option to CompileUnit's FindLineEntry API. llvm-svn: 140362
1 parent b9a1132 commit 87df91b

34 files changed

+690
-169
lines changed

lldb/include/lldb/API/SBCompileUnit.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ class SBCompileUnit
4747
uint32_t line,
4848
lldb::SBFileSpec *inline_file_spec) const;
4949

50+
uint32_t
51+
FindLineEntryIndex (uint32_t start_idx,
52+
uint32_t line,
53+
lldb::SBFileSpec *inline_file_spec,
54+
bool exact) const;
55+
5056
#ifndef SWIG
5157

5258
bool

lldb/include/lldb/API/SBFileSpecList.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ class SBFileSpecList
4444
Clear();
4545

4646
uint32_t
47-
FindFileIndex (uint32_t idx, const SBFileSpec &sb_file);
47+
FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full);
4848

4949
const SBFileSpec
5050
GetFileSpecAtIndex (uint32_t idx) const;
5151

5252
private:
5353

54+
friend class SBTarget;
55+
5456
#ifndef SWIG
5557

5658
const lldb_private::FileSpecList *

lldb/include/lldb/API/SBTarget.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "lldb/API/SBAddress.h"
1515
#include "lldb/API/SBBroadcaster.h"
1616
#include "lldb/API/SBFileSpec.h"
17+
#include "lldb/API/SBFileSpecList.h"
1718
#include "lldb/API/SBType.h"
1819

1920
namespace lldb {
@@ -314,11 +315,28 @@ class SBTarget
314315
lldb::SBBreakpoint
315316
BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
316317

318+
lldb::SBBreakpoint
319+
BreakpointCreateByName (const char *symbol_name,
320+
const SBFileSpecList &module_list,
321+
const SBFileSpecList &comp_unit_list);
322+
317323
lldb::SBBreakpoint
318324
BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
319325

320326
lldb::SBBreakpoint
321-
BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
327+
BreakpointCreateByRegex (const char *symbol_name_regex,
328+
const SBFileSpecList &module_list,
329+
const SBFileSpecList &comp_unit_list);
330+
331+
lldb::SBBreakpoint
332+
BreakpointCreateBySourceRegex (const char *source_regex,
333+
const lldb::SBFileSpec &source_file,
334+
const char *module_name = NULL);
335+
336+
lldb::SBBreakpoint
337+
BreakpointCreateBySourceRegex (const char *source_regex,
338+
const SBFileSpecList &module_list,
339+
const lldb::SBFileSpecList &source_file);
322340

323341
lldb::SBBreakpoint
324342
BreakpointCreateByAddress (addr_t address);

lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class BreakpointResolverFileRegex :
2929
{
3030
public:
3131
BreakpointResolverFileRegex (Breakpoint *bkpt,
32-
const FileSpec &resolver,
3332
RegularExpression &regex);
3433

3534
virtual
@@ -58,8 +57,7 @@ class BreakpointResolverFileRegex :
5857

5958
protected:
6059
friend class Breakpoint;
61-
FileSpec m_file_spec; // This is the file spec we are looking for.
62-
RegularExpression m_regex; // This is the line number that we are looking for.
60+
RegularExpression m_regex; // This is the line expression that we are looking for.
6361

6462
private:
6563
DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex);

lldb/include/lldb/Core/FileSpecList.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,15 @@ class FileSpecList
116116
/// @param[in] file
117117
/// The file specification to search for.
118118
///
119+
/// @param[in] full
120+
/// Should FileSpec::Equal be called with "full" true or false.
121+
///
119122
/// @return
120123
/// The index of the file that matches \a file if it is found,
121124
/// else UINT32_MAX is returned.
122125
//------------------------------------------------------------------
123126
uint32_t
124-
FindFileIndex (uint32_t idx, const FileSpec &file) const;
127+
FindFileIndex (uint32_t idx, const FileSpec &file, bool full) const;
125128

126129
//------------------------------------------------------------------
127130
/// Get file at index.

lldb/include/lldb/Core/SearchFilter.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,21 @@ class SearchFilter
216216
virtual void
217217
SearchInModuleList (Searcher &searcher, ModuleList &modules);
218218

219+
//------------------------------------------------------------------
220+
/// This determines which items are REQUIRED for the filter to pass.
221+
/// For instance, if you are filtering by Compilation Unit, obviously
222+
/// symbols that have no compilation unit can't pass So return eSymbolContextCU
223+
/// and search callbacks can then short cut the search to avoid looking at
224+
/// things that obviously won't pass.
225+
///
226+
/// @return
227+
/// The required elements for the search, which is an or'ed together
228+
/// set of lldb:SearchContextItem enum's.
229+
///
230+
//------------------------------------------------------------------
231+
virtual uint32_t
232+
GetFilterRequiredItems ();
233+
219234
//------------------------------------------------------------------
220235
/// Prints a canonical description for the search filter to the stream \a s.
221236
///
@@ -311,6 +326,9 @@ class SearchFilterByModule :
311326
virtual void
312327
GetDescription(Stream *s);
313328

329+
virtual uint32_t
330+
GetFilterRequiredItems ();
331+
314332
virtual void
315333
Dump (Stream *s) const;
316334

@@ -369,6 +387,65 @@ class SearchFilterByModuleList :
369387
virtual void
370388
GetDescription(Stream *s);
371389

390+
virtual uint32_t
391+
GetFilterRequiredItems ();
392+
393+
virtual void
394+
Dump (Stream *s) const;
395+
396+
virtual void
397+
Search (Searcher &searcher);
398+
399+
private:
400+
FileSpecList m_module_spec_list;
401+
};
402+
403+
class SearchFilterByModuleListAndCU :
404+
public SearchFilterByModuleList
405+
{
406+
public:
407+
408+
//------------------------------------------------------------------
409+
/// The basic constructor takes a Target, which gives the space to search,
410+
/// and the module list to restrict the search to.
411+
///
412+
/// @param[in] target
413+
/// The Target that provides the module list to search.
414+
///
415+
/// @param[in] module
416+
/// The Module that limits the search.
417+
//------------------------------------------------------------------
418+
SearchFilterByModuleListAndCU (lldb::TargetSP &targetSP,
419+
const FileSpecList &module_list,
420+
const FileSpecList &cu_list);
421+
422+
SearchFilterByModuleListAndCU (const SearchFilterByModuleListAndCU& rhs);
423+
424+
virtual
425+
~SearchFilterByModuleListAndCU ();
426+
427+
const SearchFilterByModuleListAndCU&
428+
operator=(const SearchFilterByModuleListAndCU& rhs);
429+
430+
virtual bool
431+
SymbolContextPasses (const SymbolContext &context,
432+
lldb::SymbolContextItem scope);
433+
434+
virtual bool
435+
AddressPasses (Address &address);
436+
437+
virtual bool
438+
CompUnitPasses (FileSpec &fileSpec);
439+
440+
virtual bool
441+
CompUnitPasses (CompileUnit &compUnit);
442+
443+
virtual void
444+
GetDescription(Stream *s);
445+
446+
virtual uint32_t
447+
GetFilterRequiredItems ();
448+
372449
virtual void
373450
Dump (Stream *s) const;
374451

@@ -377,6 +454,7 @@ class SearchFilterByModuleList :
377454

378455
private:
379456
FileSpecList m_module_spec_list;
457+
FileSpecList m_cu_spec_list;
380458
};
381459

382460
} // namespace lldb_private

lldb/include/lldb/Symbol/CompileUnit.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ class CompileUnit :
202202
/// else if NULL, search for line entries that match the compile
203203
/// unit file.
204204
///
205+
/// @param[in] exact
206+
/// If \btrue match only if there is a line table entry for this line number.
207+
/// If \bfalse, find the line table entry equal to or after this line number.
208+
///
205209
/// @param[out] line_entry
206210
/// If non-NULL, a copy of the line entry that was found.
207211
///
@@ -213,6 +217,7 @@ class CompileUnit :
213217
FindLineEntry (uint32_t start_idx,
214218
uint32_t line,
215219
const FileSpec* file_spec_ptr,
220+
bool exact,
216221
LineEntry *line_entry);
217222

218223
//------------------------------------------------------------------

lldb/include/lldb/Target/Target.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ class Target :
250250
bool check_inlines,
251251
bool internal = false);
252252

253-
// Use this to create breakpoint that matches regex against the source lines in file:
253+
// Use this to create breakpoint that matches regex against the source lines in files given in source_file_list:
254254
lldb::BreakpointSP
255-
CreateBreakpoint (const FileSpecList *containingModules,
256-
const FileSpec &file,
255+
CreateSourceRegexBreakpoint (const FileSpecList *containingModules,
256+
const FileSpecList *source_file_list,
257257
RegularExpression &source_regex,
258258
bool internal = false);
259259

@@ -267,11 +267,12 @@ class Target :
267267
CreateBreakpoint (Address &addr,
268268
bool internal = false);
269269

270-
// Use this to create a function breakpoint by regexp in containingModule, or all modules if it is NULL
270+
// Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL
271271
// When "skip_prologue is set to eLazyBoolCalculate, we use the current target
272272
// setting, else we use the values passed in
273273
lldb::BreakpointSP
274-
CreateBreakpoint (const FileSpecList *containingModules,
274+
CreateFuncRegexBreakpoint (const FileSpecList *containingModules,
275+
const FileSpecList *containingSourceFiles,
275276
RegularExpression &func_regexp,
276277
bool internal = false,
277278
LazyBool skip_prologue = eLazyBoolCalculate);
@@ -281,6 +282,7 @@ class Target :
281282
// setting, else we use the values passed in
282283
lldb::BreakpointSP
283284
CreateBreakpoint (const FileSpecList *containingModules,
285+
const FileSpecList *containingSourceFiles,
284286
const char *func_name,
285287
uint32_t func_name_type_mask,
286288
bool internal = false,
@@ -889,6 +891,10 @@ class Target :
889891

890892
lldb::SearchFilterSP
891893
GetSearchFilterForModuleList (const FileSpecList *containingModuleList);
894+
895+
lldb::SearchFilterSP
896+
GetSearchFilterForModuleAndCUList (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles);
897+
892898

893899
static void
894900
ImageSearchPathsChanged (const PathMappingList &path_list,

lldb/scripts/Python/interface/SBCompileUnit.i

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ public:
7171
uint32_t line,
7272
lldb::SBFileSpec *inline_file_spec) const;
7373

74+
uint32_t
75+
FindLineEntryIndex (uint32_t start_idx,
76+
uint32_t line,
77+
lldb::SBFileSpec *inline_file_spec,
78+
bool exact) const;
79+
7480
bool
7581
GetDescription (lldb::SBStream &description);
7682
};

lldb/scripts/Python/interface/SBFileSpecList.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public:
3434
Clear();
3535

3636
uint32_t
37-
FindFileIndex (uint32_t idx, const SBFileSpec &sb_file);
37+
FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full);
3838

3939
const SBFileSpec
4040
GetFileSpecAtIndex (uint32_t idx) const;

lldb/source/API/SBCompileUnit.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ SBCompileUnit::GetLineEntryAtIndex (uint32_t idx) const
9898

9999
uint32_t
100100
SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec) const
101+
{
102+
const bool exact = true;
103+
return FindLineEntryIndex (start_idx, line, inline_file_spec, exact);
104+
}
105+
106+
uint32_t
107+
SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec, bool exact) const
101108
{
102109
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
103110

@@ -114,6 +121,7 @@ SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec
114121
index = m_opaque_ptr->FindLineEntry (start_idx,
115122
line,
116123
inline_file_spec ? inline_file_spec->get() : NULL,
124+
exact,
117125
NULL);
118126
}
119127

lldb/source/API/SBFileSpecList.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ SBFileSpecList::Clear()
8080
}
8181

8282
uint32_t
83-
SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file)
83+
SBFileSpecList::FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full)
8484
{
85-
return m_opaque_ap->FindFileIndex (idx, sb_file.ref());
85+
return m_opaque_ap->FindFileIndex (idx, sb_file.ref(), full);
8686
}
8787

8888
const SBFileSpec

0 commit comments

Comments
 (0)