summaryrefslogtreecommitdiff
path: root/src/lj_debug.c
diff options
context:
space:
mode:
authorMike Pall <mike>2013-02-27 21:17:27 +0100
committerMike Pall <mike>2013-02-27 21:28:28 +0100
commit116cdd7e9a578efffa5a9ca38167d059d12296d7 (patch)
treecc78e44c4b7a2175f2b16bc5f8898597a72bb228 /src/lj_debug.c
parent28cfcf77445e144335961a020e3e08d84cf0091f (diff)
downloadluajit-116cdd7e9a578efffa5a9ca38167d059d12296d7.tar.gz
luajit-116cdd7e9a578efffa5a9ca38167d059d12296d7.tar.bz2
luajit-116cdd7e9a578efffa5a9ca38167d059d12296d7.zip
String buffer refactoring, part 2.
Switch to pointers for start/pos/end of buffer. Abstract out some buffer writers.
Diffstat (limited to 'src/lj_debug.c')
-rw-r--r--src/lj_debug.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/lj_debug.c b/src/lj_debug.c
index ec56b7d2..3f502864 100644
--- a/src/lj_debug.c
+++ b/src/lj_debug.c
@@ -9,6 +9,7 @@
9#include "lj_obj.h" 9#include "lj_obj.h"
10#include "lj_err.h" 10#include "lj_err.h"
11#include "lj_debug.h" 11#include "lj_debug.h"
12#include "lj_buf.h"
12#include "lj_str.h" 13#include "lj_str.h"
13#include "lj_tab.h" 14#include "lj_tab.h"
14#include "lj_state.h" 15#include "lj_state.h"
@@ -133,20 +134,6 @@ static BCLine debug_frameline(lua_State *L, GCfunc *fn, cTValue *nextframe)
133 134
134/* -- Variable names ------------------------------------------------------ */ 135/* -- Variable names ------------------------------------------------------ */
135 136
136/* Read ULEB128 value. */
137static uint32_t debug_read_uleb128(const uint8_t **pp)
138{
139 const uint8_t *p = *pp;
140 uint32_t v = *p++;
141 if (LJ_UNLIKELY(v >= 0x80)) {
142 int sh = 0;
143 v &= 0x7f;
144 do { v |= ((*p & 0x7f) << (sh += 7)); } while (*p++ >= 0x80);
145 }
146 *pp = p;
147 return v;
148}
149
150/* Get name of a local variable from slot number and PC. */ 137/* Get name of a local variable from slot number and PC. */
151static const char *debug_varname(const GCproto *pt, BCPos pc, BCReg slot) 138static const char *debug_varname(const GCproto *pt, BCPos pc, BCReg slot)
152{ 139{
@@ -162,9 +149,9 @@ static const char *debug_varname(const GCproto *pt, BCPos pc, BCReg slot)
162 } else { 149 } else {
163 while (*p++) ; /* Skip over variable name string. */ 150 while (*p++) ; /* Skip over variable name string. */
164 } 151 }
165 lastpc = startpc = lastpc + debug_read_uleb128(&p); 152 lastpc = startpc = lastpc + lj_buf_ruleb128((const char **)&p);
166 if (startpc > pc) break; 153 if (startpc > pc) break;
167 endpc = startpc + debug_read_uleb128(&p); 154 endpc = startpc + lj_buf_ruleb128((const char **)&p);
168 if (pc < endpc && slot-- == 0) { 155 if (pc < endpc && slot-- == 0) {
169 if (vn < VARNAME__MAX) { 156 if (vn < VARNAME__MAX) {
170#define VARNAMESTR(name, str) str "\0" 157#define VARNAMESTR(name, str) str "\0"