Skip to content

Commit 5009f9d

Browse files
author
Greg Clayton
committed
Added support for the new ".apple_objc" accelerator tables. These tables are
in the same hashed format as the ".apple_names", but they map objective C class names to all of the methods and class functions. We need to do this because in the DWARF the methods for Objective C are never contained in the class definition, they are scattered about at the translation unit level and they don't even have attributes that say the are contained within the class itself. Added 3 new formats which can be used to display data: eFormatAddressInfo eFormatHexFloat eFormatInstruction eFormatAddressInfo describes an address such as function+offset and file+line, or symbol + offset, or constant data (c string, 2, 4, 8, or 16 byte constants). The format character for this is "A", the long format is "address". eFormatHexFloat will print out the hex float format that compilers tend to use. The format character for this is "X", the long format is "hex float". eFormatInstruction will print out disassembly with bytes and it will use the current target's architecture. The format character for this is "i" (which used to be being used for the integer format, but the integer format also has "d", so we gave the "i" format to disassembly), the long format is "instruction". Mate the lldb::FormatterChoiceCriterion enumeration private as it should have been from the start. It is very specialized and doesn't belong in the public API. llvm-svn: 143114
1 parent 305bbb7 commit 5009f9d

24 files changed

+352
-169
lines changed

lldb/include/lldb/Core/DataExtractor.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,16 @@ class DataExtractor
274274
/// The offset at which dumping ended.
275275
//------------------------------------------------------------------
276276
uint32_t
277-
Dump(Stream *s,
278-
uint32_t offset,
279-
lldb::Format item_format,
280-
uint32_t item_byte_size,
281-
uint32_t item_count,
282-
uint32_t num_per_line,
283-
uint64_t base_addr,
284-
uint32_t item_bit_size,
285-
uint32_t item_bit_offset) const;
277+
Dump (Stream *s,
278+
uint32_t offset,
279+
lldb::Format item_format,
280+
uint32_t item_byte_size,
281+
uint32_t item_count,
282+
uint32_t num_per_line,
283+
uint64_t base_addr,
284+
uint32_t item_bit_size,
285+
uint32_t item_bit_offset,
286+
ExecutionContextScope *exe_scope = NULL) const;
286287

287288
//------------------------------------------------------------------
288289
/// Dump a UUID value at \a offset.

lldb/include/lldb/Core/Disassembler.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ class InstructionList
169169
void
170170
Append (lldb::InstructionSP &inst_sp);
171171

172+
void
173+
Dump (Stream *s,
174+
bool show_address,
175+
bool show_bytes,
176+
const ExecutionContext* exe_ctx);
177+
172178
private:
173179
typedef std::vector<lldb::InstructionSP> collection;
174180
typedef collection::iterator iterator;
@@ -178,7 +184,7 @@ class InstructionList
178184
};
179185

180186
class PseudoInstruction :
181-
public lldb_private::Instruction
187+
public Instruction
182188
{
183189
public:
184190

@@ -188,11 +194,11 @@ class PseudoInstruction :
188194
~PseudoInstruction ();
189195

190196
virtual void
191-
Dump (lldb_private::Stream *s,
197+
Dump (Stream *s,
192198
uint32_t max_opcode_byte_size,
193199
bool show_address,
194200
bool show_bytes,
195-
const lldb_private::ExecutionContext* exe_ctx,
201+
const ExecutionContext* exe_ctx,
196202
bool raw);
197203

198204
virtual bool
@@ -217,8 +223,8 @@ class PseudoInstruction :
217223
}
218224

219225
virtual size_t
220-
Decode (const lldb_private::Disassembler &disassembler,
221-
const lldb_private::DataExtractor &data,
226+
Decode (const Disassembler &disassembler,
227+
const DataExtractor &data,
222228
uint32_t data_offset);
223229

224230
void

lldb/include/lldb/Core/FormatNavigator.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
// Project includes
2727
#include "lldb/lldb-public.h"
28-
#include "lldb/lldb-enumerations.h"
2928

3029
#include "lldb/Core/FormatClasses.h"
3130
#include "lldb/Core/Log.h"
@@ -262,7 +261,7 @@ class FormatNavigator
262261
lldb::DynamicValueType use_dynamic,
263262
uint32_t* why = NULL)
264263
{
265-
uint32_t value = lldb::eFormatterChoiceCriterionDirectChoice;
264+
uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice;
266265
clang::QualType type = clang::QualType::getFromOpaquePtr(valobj.GetClangType());
267266
bool ret = Get(valobj, type, entry, use_dynamic, value);
268267
if (ret)
@@ -423,7 +422,7 @@ class FormatNavigator
423422
}
424423
if (Get_ObjC(valobj, parent, entry, reason))
425424
{
426-
reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses;
425+
reason |= lldb_private::eFormatterChoiceCriterionNavigatedBaseClasses;
427426
return true;
428427
}
429428
return false;
@@ -468,7 +467,7 @@ class FormatNavigator
468467
}
469468
else
470469
{
471-
reason |= lldb::eFormatterChoiceCriterionStrippedBitField;
470+
reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
472471
if (log)
473472
log->Printf("no bitfield direct match");
474473
}
@@ -493,7 +492,7 @@ class FormatNavigator
493492
log->Printf("stripping reference");
494493
if (Get(valobj,type.getNonReferenceType(),entry, use_dynamic, reason) && !entry->m_skip_references)
495494
{
496-
reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference;
495+
reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
497496
return true;
498497
}
499498
}
@@ -514,7 +513,7 @@ class FormatNavigator
514513
{
515514
if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason))
516515
{
517-
reason |= lldb::eFormatterChoiceCriterionDynamicObjCHierarchy;
516+
reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCHierarchy;
518517
return true;
519518
}
520519
}
@@ -535,7 +534,7 @@ class FormatNavigator
535534
clang::QualType pointee = typePtr->getPointeeType();
536535
if (Get(valobj, pointee, entry, use_dynamic, reason) && !entry->m_skip_pointers)
537536
{
538-
reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference;
537+
reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
539538
return true;
540539
}
541540
}
@@ -557,7 +556,7 @@ class FormatNavigator
557556
{
558557
if (Get_ObjC(valobj, runtime->GetISA(valobj), entry, reason))
559558
{
560-
reason |= lldb::eFormatterChoiceCriterionDynamicObjCHierarchy;
559+
reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCHierarchy;
561560
return true;
562561
}
563562
}
@@ -576,7 +575,7 @@ class FormatNavigator
576575
return false;
577576
if (Get(*target, typePtr->getPointeeType(), entry, use_dynamic, reason) && !entry->m_skip_pointers)
578577
{
579-
reason |= lldb::eFormatterChoiceCriterionStrippedPointerReference;
578+
reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
580579
return true;
581580
}
582581
}
@@ -601,7 +600,7 @@ class FormatNavigator
601600
clang::QualType ivar_qual_type(ast->getObjCInterfaceType(superclass_interface_decl));
602601
if (Get(valobj, ivar_qual_type, entry, use_dynamic, reason) && entry->m_cascades)
603602
{
604-
reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses;
603+
reason |= lldb_private::eFormatterChoiceCriterionNavigatedBaseClasses;
605604
return true;
606605
}
607606
}
@@ -630,7 +629,7 @@ class FormatNavigator
630629
{
631630
if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades)
632631
{
633-
reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses;
632+
reason |= lldb_private::eFormatterChoiceCriterionNavigatedBaseClasses;
634633
return true;
635634
}
636635
}
@@ -644,7 +643,7 @@ class FormatNavigator
644643
{
645644
if ((Get(valobj, pos->getType(), entry, use_dynamic, reason)) && entry->m_cascades)
646645
{
647-
reason |= lldb::eFormatterChoiceCriterionNavigatedBaseClasses;
646+
reason |= lldb_private::eFormatterChoiceCriterionNavigatedBaseClasses;
648647
return true;
649648
}
650649
}
@@ -660,7 +659,7 @@ class FormatNavigator
660659
log->Printf("stripping typedef");
661660
if ((Get(valobj, type_tdef->getDecl()->getUnderlyingType(), entry, use_dynamic, reason)) && entry->m_cascades)
662661
{
663-
reason |= lldb::eFormatterChoiceCriterionNavigatedTypedefs;
662+
reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs;
664663
return true;
665664
}
666665
}

lldb/include/lldb/Interpreter/OptionGroupFormat.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ namespace lldb_private {
2626
class OptionGroupFormat : public OptionGroup
2727
{
2828
public:
29-
static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
30-
static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_2;
31-
static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_3;
29+
static const uint32_t OPTION_GROUP_FORMAT = LLDB_OPT_SET_1;
30+
static const uint32_t OPTION_GROUP_GDB_FMT = LLDB_OPT_SET_2;
31+
static const uint32_t OPTION_GROUP_SIZE = LLDB_OPT_SET_3;
32+
static const uint32_t OPTION_GROUP_COUNT = LLDB_OPT_SET_4;
3233

3334
OptionGroupFormat (lldb::Format default_format,
3435
uint64_t default_byte_size = UINT64_MAX, // Pass UINT64_MAX to disable the "--size" option

lldb/include/lldb/Symbol/ClangASTType.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ class ClangASTType
148148
uint32_t data_offset,
149149
size_t data_byte_size,
150150
uint32_t bitfield_bit_size,
151-
uint32_t bitfield_bit_offset);
151+
uint32_t bitfield_bit_offset,
152+
ExecutionContextScope *exe_scope);
152153

153154

154155
static bool
@@ -160,7 +161,8 @@ class ClangASTType
160161
uint32_t data_offset,
161162
size_t data_byte_size,
162163
uint32_t bitfield_bit_size,
163-
uint32_t bitfield_bit_offset);
164+
uint32_t bitfield_bit_offset,
165+
ExecutionContextScope *exe_scope);
164166

165167
void
166168
DumpSummary (ExecutionContext *exe_ctx,

lldb/include/lldb/lldb-enumerations.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,11 @@ namespace lldb {
117117
eFormatVectorOfFloat32,
118118
eFormatVectorOfFloat64,
119119
eFormatVectorOfUInt128,
120-
eFormatComplexInteger, // Integer complex type
121-
eFormatCharArray, // Print characters with no single quotes, used for character arrays that can contain non printable characters
120+
eFormatComplexInteger, // Integer complex type
121+
eFormatCharArray, // Print characters with no single quotes, used for character arrays that can contain non printable characters
122+
eFormatAddressInfo, // Describe what an address points to (func + offset with file/line, symbol + offset, data, etc)
123+
eFormatHexFloat, // ISO C99 hex float string
124+
eFormatInstruction, // Disassemble an opcode
122125
kNumFormats
123126
} Format;
124127

@@ -479,6 +482,7 @@ namespace lldb {
479482
eSectionTypeDWARFAppleNames,
480483
eSectionTypeDWARFAppleTypes,
481484
eSectionTypeDWARFAppleNamespaces,
485+
eSectionTypeDWARFAppleObjC,
482486
eSectionTypeEHFrame,
483487
eSectionTypeOther
484488

@@ -507,20 +511,6 @@ namespace lldb {
507511
eFunctionNameTypeSelector = (1u << 5) // Find function by selector name (ObjC) names
508512
} FunctionNameType;
509513

510-
//----------------------------------------------------------------------
511-
// Ways that the FormatManager picks a particular format for a type
512-
//----------------------------------------------------------------------
513-
typedef enum FormatterChoiceCriterion
514-
{
515-
eFormatterChoiceCriterionDirectChoice = 0x00000000,
516-
eFormatterChoiceCriterionStrippedPointerReference = 0x00000001,
517-
eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002,
518-
eFormatterChoiceCriterionNavigatedBaseClasses = 0x00000004,
519-
eFormatterChoiceCriterionRegularExpressionSummary = 0x00000008,
520-
eFormatterChoiceCriterionRegularExpressionFilter = 0x00000008,
521-
eFormatterChoiceCriterionDynamicObjCHierarchy = 0x00000010,
522-
eFormatterChoiceCriterionStrippedBitField = 0x00000020
523-
} FormatterChoiceCriterion;
524514

525515
//----------------------------------------------------------------------
526516
// Basic types enumeration for the public API SBType::GetBasicType()

lldb/include/lldb/lldb-private-enumerations.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,22 @@ typedef enum {
222222
eExecutionPolicyNever,
223223
eExecutionPolicyAlways
224224
} ExecutionPolicy;
225-
225+
226+
//----------------------------------------------------------------------
227+
// Ways that the FormatManager picks a particular format for a type
228+
//----------------------------------------------------------------------
229+
typedef enum FormatterChoiceCriterion
230+
{
231+
eFormatterChoiceCriterionDirectChoice = 0x00000000,
232+
eFormatterChoiceCriterionStrippedPointerReference = 0x00000001,
233+
eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002,
234+
eFormatterChoiceCriterionNavigatedBaseClasses = 0x00000004,
235+
eFormatterChoiceCriterionRegularExpressionSummary = 0x00000008,
236+
eFormatterChoiceCriterionRegularExpressionFilter = 0x00000008,
237+
eFormatterChoiceCriterionDynamicObjCHierarchy = 0x00000010,
238+
eFormatterChoiceCriterionStrippedBitField = 0x00000020
239+
} FormatterChoiceCriterion;
240+
226241
} // namespace lldb
227242

228243

lldb/source/Commands/CommandObjectExpression.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interprete
164164
// Push the data for the first argument into the m_arguments vector.
165165
m_arguments.push_back (arg);
166166

167-
// Add the "--format" and "--count" options to group 1 and 3
168-
m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_1);
167+
// Add the "--format" and "--gdb-format"
168+
m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1);
169169
m_option_group.Append (&m_command_options);
170170
m_option_group.Finalize();
171171
}

lldb/source/Commands/CommandObjectFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class CommandObjectFrameVariable : public CommandObject
355355
m_arguments.push_back (arg);
356356

357357
m_option_group.Append (&m_option_variable, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
358-
m_option_group.Append (&m_option_format, OptionGroupFormat::OPTION_GROUP_FORMAT, LLDB_OPT_SET_1);
358+
m_option_group.Append (&m_option_format, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1);
359359
m_option_group.Append (&m_option_watchpoint, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
360360
m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
361361
m_option_group.Finalize();

lldb/source/Commands/CommandObjectMemory.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,21 @@ class OptionGroupReadMemory : public OptionGroup
136136

137137
case eFormatCString:
138138
break;
139-
139+
140+
case eFormatInstruction:
141+
if (count_option_set)
142+
byte_size_value = target->GetArchitecture().GetMaximumOpcodeByteSize() * format_options.GetCountValue().GetCurrentValue();
143+
m_num_per_line = 1;
144+
break;
145+
146+
case eFormatAddressInfo:
147+
if (!byte_size_option_set)
148+
byte_size_value = target->GetArchitecture().GetAddressByteSize();
149+
m_num_per_line = 1;
150+
if (!count_option_set)
151+
format_options.GetCountValue() = 8;
152+
break;
153+
140154
case eFormatPointer:
141155
byte_size_value = target->GetArchitecture().GetAddressByteSize();
142156
if (!num_per_line_option_set)
@@ -153,14 +167,15 @@ class OptionGroupReadMemory : public OptionGroup
153167
case eFormatUnicode16:
154168
case eFormatUnicode32:
155169
case eFormatUnsigned:
170+
case eFormatHexFloat:
156171
if (!byte_size_option_set)
157172
byte_size_value = 4;
158173
if (!num_per_line_option_set)
159174
m_num_per_line = 1;
160175
if (!count_option_set)
161176
format_options.GetCountValue() = 8;
162177
break;
163-
178+
164179
case eFormatBytes:
165180
case eFormatBytesWithASCII:
166181
if (byte_size_option_set)
@@ -309,6 +324,9 @@ class CommandObjectMemoryRead : public CommandObject
309324
m_option_group.Append (&m_format_options,
310325
OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_COUNT,
311326
LLDB_OPT_SET_1 | LLDB_OPT_SET_3);
327+
m_option_group.Append (&m_format_options,
328+
OptionGroupFormat::OPTION_GROUP_GDB_FMT,
329+
LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3);
312330
// Add the "--size" option to group 1 and 2
313331
m_option_group.Append (&m_format_options,
314332
OptionGroupFormat::OPTION_GROUP_SIZE,
@@ -653,6 +671,7 @@ class CommandObjectMemoryRead : public CommandObject
653671
}
654672

655673

674+
ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope();
656675
if (clang_ast_type.GetOpaqueQualType())
657676
{
658677
for (uint32_t i = 0; i<item_count; ++i)
@@ -661,7 +680,7 @@ class CommandObjectMemoryRead : public CommandObject
661680
Address address (NULL, item_addr);
662681
StreamString name_strm;
663682
name_strm.Printf ("0x%llx", item_addr);
664-
ValueObjectSP valobj_sp (ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(),
683+
ValueObjectSP valobj_sp (ValueObjectMemory::Create (exe_scope,
665684
name_strm.GetString().c_str(),
666685
address,
667686
clang_ast_type));
@@ -715,7 +734,8 @@ class CommandObjectMemoryRead : public CommandObject
715734
num_per_line,
716735
addr,
717736
0,
718-
0);
737+
0,
738+
exe_scope);
719739
output_stream->EOL();
720740
return true;
721741
}
@@ -1030,6 +1050,9 @@ class CommandObjectMemoryWrite : public CommandObject
10301050
case eFormatVectorOfUInt128:
10311051
case eFormatOSType:
10321052
case eFormatComplexInteger:
1053+
case eFormatAddressInfo:
1054+
case eFormatHexFloat:
1055+
case eFormatInstruction:
10331056
result.AppendError("unsupported format for writing memory");
10341057
result.SetStatus(eReturnStatusFailed);
10351058
return false;

0 commit comments

Comments
 (0)